Created
October 30, 2013 14:43
-
-
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
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 | |
| // 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 →</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