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);
}

Resources:
http://stackoverflow.com/questions/4082662/multiple-excerpt-lengths-in-wordpress
http://codex.wordpress.org/Function_Reference/wp_trim_words
http://codex.wordpress.org/Function_Reference/get_the_content

Published by

MikeGrace

I am a Geek! I hope you enjoyed this recent post.