Skip to content

Instantly share code, notes, and snippets.

@josephhinson
Created October 30, 2013 14:43
Show Gist options
  • Select an option

  • Save josephhinson/7233830 to your computer and use it in GitHub Desktop.

Select an option

Save josephhinson/7233830 to your computer and use it in GitHub Desktop.
[WordPress] When you want to add "Read More" to all excerpts, regardless of length
<?php
// Excerpt Filter this will remove any text added to the excerpt
function new_excerpt_more($more) {
global $post;
return '';
}
// This will append the excerpt with additional text, "Read More"
function the_excerpt_always_show_read_more($content) {
global $post;
// Only manually add the link if the excerpt was manually written
// otherwise WP generated excerpts will never trigger
return $content . '...<br /><strong><a class="learn-more" href="'.get_permalink($post->ID).'">Read More &rarr;</a></strong>';
}
add_filter( 'get_the_excerpt', 'the_excerpt_always_show_read_more');
add_filter('excerpt_more', 'new_excerpt_more');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment