Quick & Easy Excerpt Mods Coming in WordPress 2.9
by c.bavota | Posted in Tutorials | 28 comments
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.
function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
Change the number “20″ to whatever number you want.
function new_excerpt_more($more) {
return '[.....]';
}
add_filter('excerpt_more', 'new_excerpt_more');
Change “[.....]” to whatever you want.



Currently what I do is use the
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?
This would make every excerpt the same length. But the thing about the excerpts is that they are stripped of all tags so that might not be what you want.
Ahh yea I wouldn’t want that. I’ll do some testing on that this weekend and see what results I come up with using this function. I also found your Limiting the Number of Words in Your Excerpt or Content in WordPress article which has spurred some ideas that relate to the Excerpt function.
This method does not work.
Are you using WordPress 2.9?
I’m impressed! You’ve managed the almost ipmosilsbe.
Will this not work in WordPress 3.0?
It works in 3.0.
Thanks so much… found your solution via google (‘limit words in wordpress excerpt’) search and it worked very well!
Kudos.
Hello,
Read more coming in one news only not in second and also it is not linking to anything?
I used this code
<?php the_date(); echo "”; ?>
<?php echo excerpt(25); echo "”;?>
sorry here is code again
<?php the_date(); echo ""; ?> <?php echo excerpt(25); echo "";?>Looks like you are on the wrong post. Are you using the Excerpt Word Limit plugin?
I only used the first one as I don’t mind the trailing at the end of excerp. It works great! I am not a programmer/coder and the type who gets stuck at every turn it gets so bad… But this worked instantly, so pleasantly surprised! Things were overlapping on my homepage but now it’s perfect. Thanks a million!