Created
June 15, 2018 09:38
-
-
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 ).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 »'; | |
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