How to change wordpress excerpt text length

by Hough on March 22, 2011

WordPress excerpt is a short summary of wordpress post automatically generated by WordPress. By default it is first 55 words of post. And can be displayed in theme with this peice of code, “the_exceprt()” . Many bloggers likes to display small excerpt on the front page, because it is one nice way to display content on front page. However you can also write your short summary additionaly. You can find it below the main content panel with the heading Excerpt.

How to change wordpress exceprt text length

However, if you want to stick to default WordPress excerpt and want to edit the length of it, it might be tough for you if you are not aware with some of the functions of WordPress. So, for those users here is some simple and easy steps for you to edit wordpress excerpt length, ie number of words.

Open functions.php file in your theme and just added following four lines code.


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

In above code you can change 30 which is number of words with your desired number. Once this thing is added, all you excerpt will be of 30 words overwriting default value of 55 words excerpt. Edit and Enjoy.

Leave a Comment

Previous post:

Next post: