Skip to content

Instantly share code, notes, and snippets.

@rushijagani
Created June 15, 2018 09:38
Show Gist options
  • Save rushijagani/4bc315f0573af30ee63db84f9c585aa7 to your computer and use it in GitHub Desktop.
Save rushijagani/4bc315f0573af30ee63db84f9c585aa7 to your computer and use it in GitHub Desktop.
Add Read More text after the excerpt (Only Excerpts which are the hand-crafted summaries of your content ).
<?php
// Add "Read More" link to excerpts only (Excerpts which are the hand-crafted summaries of your content ))
add_filter('get_the_excerpt', 'custom_excerpt_read_more_link');
function custom_excerpt_read_more_link($excerpt) {
$excerpt_more = '';
$read_more_text = 'Read More &raquo;';
if ( has_excerpt() && ! is_attachment() && get_post_type() == 'post' ) {
$excerpt_more = '<p class="read-more" ><a href="' . esc_url( get_permalink() ) . '"> '. $read_more_text . '</a></p>';
}
return $excerpt . $excerpt_more;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment