in this page /
Last post is with excerpt.
If my posts don´t have excerpt show read more If I add excerpt the button doesn´t show.
In functions.php
// Replaces the excerpt "Read More" text by a link
function clean_blogging_excerpt_more($more) {
if ( is_admin() ) {
return $more;
}
global $post;
return '<p><a class="readmore" href="'. get_permalink($post->ID) . '">Leer Más</a></p>';
}
add_filter('excerpt_more', 'clean_blogging_excerpt_more');
in this page https://blog.despierta/page/3/
Last post is with excerpt.
If my posts don´t have excerpt show read more If I add excerpt the button doesn´t show.
In functions.php
// Replaces the excerpt "Read More" text by a link
function clean_blogging_excerpt_more($more) {
if ( is_admin() ) {
return $more;
}
global $post;
return '<p><a class="readmore" href="'. get_permalink($post->ID) . '">Leer Más</a></p>';
}
add_filter('excerpt_more', 'clean_blogging_excerpt_more');
Share
Improve this question
edited Mar 22, 2019 at 14:10
cjbj
15k16 gold badges42 silver badges89 bronze badges
asked Mar 22, 2019 at 13:18
En Código WPEn Código WP
213 bronze badges
1 Answer
Reset to default 1You are using the wrong filter. Depending on how your theme is built, there may be two solutions.
If the theme uses the
wp_trim_excerpt
function, theexcerpt_more
filter inside that function will only be called if there is no excerpt passed to that function. At the end of that function there still is thewp_trim_excerpt
filter that you could use to append anything to the result.If the theme uses the
get_the_excerpt
function to echo the excerpt there is a filter with the same name that you may use.
Both solutions may work at the same time, so don't overdo it.