In many WordPress themes blog posts display a brief excerpt instead of the full text. These themes utilize the WordPress function the_excerpt() in their files, which then renders the first 55 words of the post by default, unless a manual excerpt is entered in the corresponding field for the post. In certain situations you may wish to have more control of what is displayed, such as changing the excerpt length. In this post we will show you how to change the excerpt length with or without a plugin.

UNLIMITED DOWNLOADS: 500,000+ WordPress & Design Assets

Sign up for Envato Elements and get unlimited downloads starting at only $16.50 per month!



How To Change The Excerpt Length In WordPress Without A Plugin

Changing the excerpt length without a plugin is relatively simple to do, even if you have little or no coding knowledge. However, the only control this gives you is over the number of words in the excerpt, nothing more. For more control options, we recommend using the plugin discussed in the next section.

Place the following code at the bottom of your theme’s functions.php file:

add_filter( 'excerpt_length', 'firstwd_excerpt_length' );
function firstwd_excerpt_length() {
    return 30;
}

Simply change the number 30 in the code to the number of words you prefer.

How To Change The Excerpt Length In WordPress With A Plugin

For much more control over the excerpt, we recommend using The Advanced Excerpt plugin. After installing this plugin you can set it up relatively easily – and without any code – to:

  1. Keep HTML markup in the excerpt (and you get to choose which tags are included)
  2. Trim the excerpt to a given length using either character count or word count
  3. Only the ‘real’ text is counted (HTML is ignored but kept)
  4. Customize the excerpt length and the ellipsis character that are used
  5. Complete the last word or sentence in an excerpt (no weird cuts)
  6. Add or remove a read-more link to the text
  7. Ignore custom excerpts and use the generated one instead
  8. Developers can use the_advanced_excerpt() for even more control (see the FAQ)

There are other plugins with similar functionality that you can use but we have used this one in hundreds of websites for many years, so we can confidently recommend it.

Now you know how to gain more control over the excerpt in your WordPress website. We hope you have found this quick tip helpful for your future projects! Be sure to check out our other WordPress tutorials while you’re at it.

This post may contain affiliate links. See our disclosure about affiliate links here.