最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论