Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Deaner666
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deaner666/0ee8719e06481f85e2b7 to your computer and use it in GitHub Desktop.
Save Deaner666/0ee8719e06481f85e2b7 to your computer and use it in GitHub Desktop.
Add 'read more' links to automatic excerpts, manual excerpts and teasers
<?php
// 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 '&hellip;&nbsp;<a href="' . get_permalink($post->ID) . '">[Continue&nbsp;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 = '&nbsp;<a href="' . get_permalink() . '">[Continue&nbsp;reading] <span class="screen-reader-text">' . get_the_title() . '</span></a>';
}
return $excerpt . $excerpt_more;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment