Created
January 21, 2017 19:23
-
-
Save geeac/f53dcba668ebcb3593c3f5d17053e640 to your computer and use it in GitHub Desktop.
Add Readmore link to excerpts
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
// Add "Read More" link to automatic excerpts | |
add_filter('the_content_more_link', 'wpm_get_read_more_link'); | |
add_filter('get_the_content_more_link', 'wpm_get_read_more_link'); // Genesis Framework only | |
add_filter('excerpt_more', 'wpm_get_read_more_link'); | |
function wpm_get_read_more_link() { | |
global $post; | |
return '… <a href="' . get_permalink($post->ID) . '">[Continue reading] <span class="screen-reader-text">' . get_the_title() . '</span></a>'; | |
} | |
// Add "Read More" link to hand-crafted excerpts | |
add_filter('get_the_excerpt', 'wpm_manual_excerpt_read_more_link'); | |
function wpm_manual_excerpt_read_more_link($excerpt) { | |
$excerpt_more = ''; | |
if (has_excerpt() && ! is_attachment() && get_post_type() == 'post') { | |
$excerpt_more = ' <a href="' . get_permalink() . '">[Continue reading] <span class="screen-reader-text">' . get_the_title() . '</span></a>'; | |
} | |
return $excerpt . $excerpt_more; | |
} | |
//Credit http://www.wpmusketeer.com/how-to-add-read-more-links-to-wordpress-excerpts/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment