Variable Length Excerpt for WordPress

If you need to change the default excerpt length you can do that through the use of the excerpt_length filter.

If you need to be able to get varying length excerpts then you can add a custom function to your theme’s functions.php file like this:

// custom length excerpt as long as inside a loop
function custom_length_excerpt($word_count_limit) {
	echo wp_trim_words(get_the_content(), $word_count_limit);