Quick Tips: excerpt filters that give you some more control

Filter in WordPress are a joy and certainly what make the framework so flexible. Like the last post on enabling menu support, this is just a quick tips on two filters introduced in WordPress 2.8 and 2.9.

excerpt_length

The name says it all, it allowd you to change the length of the excerpt displayed. The usage is very simple:

[snippet-Excerpt length]

The above function changes the number of words returned by the excerpt to 40. The code goes in your theme functions.php.

excerpt_more

Again pretty self explanatory, this one changes the end of the excerpt to whatever you want. For example, to add a link you would add this to your functions.php:

[snippet-read_more]

This code will add a ‘Continue Reading’ link at the end of each excerpt and change the default ‘[…]’ at the end to ‘…’

Leave a Reply

Your email address will not be published. Required fields are marked *