How to Change / Shorten Excerpt Length in WordPress

Most index pages, archive pages in WordPress display excerpts of 55 words. How can you change, or shorten excerpt length (or even increase it) easily. Its become important because if you have a large site and Google is indexing thousands of archive pages in tags and categories, then these excerpts can lead to duplicate content issues and lead to a Google penalty.

WordPress Excerpts

If you look inside your WordPress theme index.php or archive.php, you will find this excerpt tag coming beneath the post title, which displays post excerpt in the front page or archives, category pages.

<?php the_excerpt(); ?>

It will display 55 words by default and then end abruptly with […]. So how can you change excerpt length?

Change excerpt length in WordPress

Edit your theme functions file functions.php and add the following code at the bottom just above the last line of the code ?>

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

Remember to place it just above the last line of the code ?> or your functions.php file may become unusable. Change the 20 and use and number to specify the words you want to display in excerpts.

Its a good idea to backup your themes file before editing it, as any error will give major WordPress theme errors. And then you would have to FTP your site, and restore the functions.php to the previous one.


  1. Tech Crates says:

    Coz of less knowledge of php, I prefer editing the excerpt length via theme options instead of editing the files. Anyways great share

  2. Swamykant says:

    I tried with some of the my blogs. It works. Thanks for sharing.

  3. Rakesh Kumar says:

    Coding is simple and easy to implement. Thanks

  4. Jasmine says:

    Good tips there. Simple, but should be useful when you want to customize the theme for example.

  5. Saket Jajodia says:

    ‘excerpt’ word is not there in my theme and there are so many prob in my theme, when I tried to contact creator of that theme, he didn’t replied.. :(

  6. Todd M. says:

    Great tips, love WordPress functions.

  7. Richard says:

    Fantastic, I love the simplicity of WordPress at times.

Leave a Reply

Your email address will not be published. Required fields are marked *