I'm trying to replace "More Details" text from the below functions using an add_filter hook
function awsm_job_more_details( $link, $view ) {
$more_dtls_link = sprintf( '<div class="awsm-job-more-container"><%1$s class="awsm-job-more"%3$s>%2$s <span></span></%1$s></div>', ( $view === 'grid' ) ? 'span' : 'a', esc_html__( 'More Details', 'wp-job-openings' ), ( $view === 'grid' ) ? '' : ' href="' . esc_url( $link ) . '"' );
echo apply_filters( 'awsm_jobs_listing_details_link', $more_dtls_link, $view );
}
What I tried.....
function example_callback( $more_dtls_link, $view ) {
$more_dtls_link = sprintf( '<div class="awsm-job-more-container"><%1$s class="awsm-job-more"%3$s>%2$s <span></span></%1$s></div>', ( $view === 'grid' ) ? 'span' : 'a', esc_html__( 'Hello World', 'wp-job-openings' ), ( $view === 'grid' ) ? '' : ' href="' . esc_url( $link ) . '"' );
return $more_dtls_link;
}
add_filter( 'awsm_jobs_listing_details_link', 'example_callback',10, 2);
Text is getting replaced to "Hello World" but the link is broken on the Button. May I know what I'm missing here??
$linkbut there is no$linkvariable. Also the filter does not pass the original$linkURL, it passes the HTML, so it doesn't work the way you thought it did. You can't copy paste the function and modify it to what you want, you'd need to do a search/replace of the HTML in$more_dtls_linkinstead. Where doesawsm_job_more_detailscome from?