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é 11 Answer
Reset to default 0Use 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;
}