The WordPress excerpt is the first part of your post, unless you use optional excerpts, and will end with […]. This is not a read more or continue reading link. The default WordPress excerpt is 55 characters.
Recently, I was working on project where the the main post page displays ads that have a very short blurb about them and then the full ad uses custom fields to display the rest of the pertinent information. One ad blurb was slightly longer than the others so we were getting the excerpt […]. Since this wasn’t happening with any other ads and was unlikely to happen very often, I decided that I wanted to make the excerpt longer so the content wouldn’t get split.
WordPress has a handy function to make this happen. Add the following to your functions file (Appearance > Editor > functions.php)
function custom_excerpt_length( $length ) { return 60; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
Change the 60 to the number of words that you would like the excerpt to have.
Do not edit your functions file without making a copy of it first. It’s easy to break your site by having an error in your functions file. If something does go awry, you can upload the copy and your site will be back to normal.
If you would like assistance making this or other changes to your site, please contact me.
photo credit: hhoyer
p90x workout says
Thank you so much for this Kim. I have been looking for a way to edit the length of the default excerpt in WordPress for awhile now. I usually don’t like when my WordPress theme will only display a small part of the excerpt.
I usually like to show my readers a little bit more of the content . Thanks again for this Kim. I will give it a try later on tonight.
– Robert
TeslaThemes says
Cool hack. Although many bloggers need this, very few know how to do it.