groups

name language licence
Untitled Snippet Other Other
maeghandonovan HTML Other
someecards Other Other
featured sliding content PHP BSD
How to change the default Wordpress excerpt PHP BSD
player PHP BSD
Excluding the Category PHP BSD
Custom post title with lead graphic background PHP BSD

< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 >



language: PHP
licence: BSD

How to change the default Wordpress excerpt

options: view full snippetsend to code collector
//Tip: How to change the default Wordpress excerpt

//Ever get tired of those nasty [...] ellipses that appear beneath your blog excerpts? I do. In this tutorial, I am going to show you how to change Wordpress’ default excerpt display without changing core Wordpress files.

//Open up functions.php and add this code to the very bottom of the file:


<?php function gpp_excerpt($text) { return str_replace('[...]', '<br /><a href="'.get_permalink().'">Read More →</a>', $text); } add_filter('the_excerpt', 'gpp_excerpt'); ?>

//The above code “filters” Wordpress’ default the_excerpt function and replaces it with our own gpp_excerpt function. We have just written a very simple plugin for Wordpress.

//If, however, you are writing your own excerpts and want to add a Read More permalink, replace:

<?php the_excerpt(); ?>

	
(Continues...)