最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

filters - Why in archive page doesn´t show read more button with excerpt?

matteradmin7PV0评论

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
Add a comment  | 

1 Answer 1

Reset to default 1

You are using the wrong filter. Depending on how your theme is built, there may be two solutions.

  1. If the theme uses the wp_trim_excerpt function, the excerpt_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 the wp_trim_excerpt filter that you could use to append anything to the result.

  2. 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.

Post a comment

comment list (0)

  1. No comments so far