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

How to automatically add Read more section after the first paragraphe in post?

programmeradmin3浏览0评论

When copywrighter publish an article, sometimes they forget to add the section Read more, and I have to do it manually. Is there a way to add it automatically in the article ?

Thank you very much.

When copywrighter publish an article, sometimes they forget to add the section Read more, and I have to do it manually. Is there a way to add it automatically in the article ?

Thank you very much.

Share Improve this question edited Jul 2, 2019 at 18:10 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Jul 2, 2019 at 9:49 Pierre MétéyéPierre Météyé 1
Add a comment  | 

1 Answer 1

Reset to default 0

Use the excerpt with a custom read more link in functions.php

add_filter( 'excerpt_length', 'modify_excerpt_length' );

function modify_excerpt_length( $length ) {

    return 15; 
}


add_filter( 'excerpt_more', 'your_excerpt_more' );

function your_excerpt_more( $more ) {

$more = sprintf( ' <a href="%s" class="read-more" rel="bookmark">' . __( 'Read More' ) . '</a>', esc_url( get_permalink() ) );

return $more;
}

Or, you can filter the_excerpt or get_the_excerpt hook like this :

add_filter( 'get_the_excerpt', 'link_read_more' );

function link_read_more( $output ) {

$more = sprintf( ' <a href="%s" class="read-more" rel="bookmark">' . __( 'Read More' ) . '</a>', esc_url( get_permalink() ) );

return $output . $more;
}
发布评论

评论列表(0)

  1. 暂无评论