Back in the day I needed to change the read more text for the post grid ,so I used this code and its working fine.
function excerpt_read_more_link($output) {
global $post;
return $output . '<a class="more-link" href="'. get_permalink($post->ID) . '">voir plus</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');
and now I add a custom post type called bouton_personnalise
and I need to check if the the author of the article field this bouton_personnalise so the read more text should be the custom post type typing by the author and if not just show the read more text so I add this code but its not working
function excerpt_read_more_link($output) {
global $post;
$text = 'voir plus';
if ( isset('bouton_personnalise'))
$text = 'bouton_personnalise';
return $output . '<a class="more-link" href="'. get_permalink($post->ID) . '">'. $text .'</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');
here is my solution in case someone has the same issue
function excerpt_read_more_link($output) {
global $post;
$li = get_field('bouton_personnalise');
$text = 'Lire plus';
if ( isset( $li) )
$text = $li;
return $output . '<a class="vc_general vc_btn3 vc_btn3-size-md vc_btn3-shape-rounded vc_btn3-style-flat vc_btn3-color-juicy-maryam" href="'. get_permalink($post->ID) . '">'. $text .'</a>';
}
add_filter('the_excerpt', 'excerpt_read_more_link');