Manipulating the default excerpt length

I am a big believer in using the manual excerpt field in WordPress (since it is not often that a simple 55 word excerpt from the beginning of the post will do the trick) but there are times when you need to control the excerpt length with a finer adjustment, and/or with a length that varies from template file to template file.

If all you want to do is to shorten the excerpt length from the default length you can place the following code in place of

It will even over-ride what is placed in the manual excerpt field (in terms of length)

The number (150) is the limit of characters and can be modified anywhere between 1-690 – after 200 (or so) you will conflict with the default excerpt thresh hold and loose the functionality.
source

Now this is all fine and good until you want a LONGER excerpt that default proscribes. If that is needed, then you need to add a function. This is close, but does nothing to shorten the manually configured excerpts:

source
But this function will also trim the manual excerpts, ands so in my mind is better:

source
Then in whichever template file you may be modifying you can set the excerpt length by ANY NUMBER OF WORDS like this (note the addition of “echo”)

And… HTML will still be respected in teh excerpt if your functions file already includes this piece of code: