Change WordPress Excerpt Length


The WordPress ‘excerpt’ is the snippet of text that is shown by default on your archive pages, such as your blog page or any of your blog category/author pages. Basically, anywhere that shows a little ‘preview’ of the text contained in your posts will be using the WordPress excerpt. This is a really handy feature that means you can very quickly set up archive pages without having to worry about creating these snippets yourself. However, what the come with a fixed length of 55 words, which is sometimes not ideal. Fortunately, if you want to change this there is a very simple bit of code you can add to your theme or child-theme’s functions.php file that will enable you to specify whatever length you want:


function wws_excerpt_length( $length ) {
return 16;
}
add_filter( 'excerpt_length', 'wws_excerpt_length', 999 );

Copy any paste that code into your functions.php file and upload it into your theme directory – just remember to change the ‘999’ figure to whatever length you want your excerpts to be, and you should be sorted. You can experiment with this too, so feel free to upload the code to test it out, then make changes to the excerpt length and re-upload it until you’re happy.

Easy!