Quick & Easy Excerpt Mods Coming in WordPress 2.9

Posted on October 28, 2009  |  Category: Tutorials

I just stumbled across these two little pieces of code and thought that they might be useful to some people out there who want to mess around with the default settings for the_excerpt() function in WordPress. The first one gives you the power to change the number of words displayed by the function the_excerpt(), and yes, you can have more than 55 words. The second piece of code allows you to change the trailing [...] that appears at the end of your excerpt.

Both features are set to be added to version 2.9 of WordPress, but the first currently works in version 2.8.5. Just add these to your theme’s functions.php file.

1
2
3
4
function new_excerpt_length($length) {
	return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
1
2
3
4
function new_excerpt_more($more) {
	return '[.....]';
}
add_filter('excerpt_more', 'new_excerpt_more');

Tags: , , , , , , , , , , , , , , , , , , ,

Short URL: http://bavotasan.com/?p=1393

5 Responses to “Quick & Easy Excerpt Mods Coming in WordPress 2.9”

  1. Currently what I do is use the

    <!--more-->

    code to limit what I want as a teaser read of the post and like most times I have to go back and forth adjusting the limit. So with the use of the Excerpt function, would this be a more sensible method?

    #5769
  2. Dan

    This method does not work.

    #7482

Leave a Reply

To enter code in the comment box, please place it between <pre lang="php"> </pre> tags. You don't have to convert any characters to their hex/HTML code. Just add your code the way you would to any code editor.