Software Developer

Change the Length of the Excerpt in WordPress

Here is the easiest and quickest way to change the length of the excerpt without a plugin in WordPress. The post excerpt is normally 55 words long. You change this by pasting some lines of code into the functions.php file of your WordPress theme. Take the following code:


function new_excerpt_length($length) {
	return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');

Make the following changes: on line 2, change the number 20 to the number of words you desire your excerpts to be. Then grab all the lines of code and paste them into your functions.php file of your WordPress theme. Be sure to place this code within the proper php tags that are already in your functions.php file.

To set different excerpt lengths for different custom post types, see:

Different Excerpt Length For Different Post Types

By

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]