How to edit the WordPress excerpt length easily
parallax background

How to edit the WordPress excerpt length easily

The Best Examples of Product Landing Pages
April 23, 2025
How to increase the WordPress memory limit
April 24, 2025
The Best Examples of Product Landing Pages
April 23, 2025
How to increase the WordPress memory limit
April 24, 2025
 

Ever struggled with long, unwieldy post previews cluttering your WordPress site? Controlling how to edit the WordPress excerpt length gives you power over how your content displays on archive pages and homepage post previews.

WordPress displays a default 55-word snippet when using the_excerpt function in your template. This one-size-fits-all approach rarely works for every site design or content strategy.

With simple modifications to your functions.php file, you can customize these content previews to match your exact needs. The WordPress hooks system makes this surprisingly straightforward, even for beginners.

In this guide, you'll learn:

  • Different methods to adjust excerpt character limit
  • How to implement the excerpt_length filter
  • Techniques for customizing your theme's display options
  • Solutions for both beginners and advanced WordPress developers

These post summary customization techniques work across WordPress templates without requiring complex PHP programming knowledge.

Why do you need to change the excerpt length? WordPress guide

 

As a WordPress user, you know how different themes can change the structure of articles, including the excerpt display. However some of the default settings really don’t fit the style and the tone of your articles.

Now you don’t have to depend on those settings. The WordPress excerpt length can be customized.. Read on to find out how.

The main reason to customize is that the standard 55 words are often inappropriate for your needs.. Much depends on the style, subject, and which language you’re using. What works for one language and its alphabet may not work for another.

Let’s take an example with the EightyDays theme:

It gives you 3 lines for the excerpt, which equals around 20 words in English. However, if you write in Arabic or Russian alphabet, you would need only 2 lines for the same amount of words. This is due to the difference between the characters. In conclusion, the EightyDays theme with the standard 3 lines of excerpt wouldn’t make your blog look as good in Russian or Arabic. This is what you need to change.

One aspect that you should take into account is that, generally, you need a longer excerpt fora 1-column grid of content. That’s why, when choosing to change the layout from 2-column to 1-column, you need to also change the length of the excerpt.

Limit your WordPress Excerpt Length to a certain number of words.

If you want to set a word limit for your excerpt, use the following code in your functions.php file.

function excerpt($limit) {

  $excerpt = explode(' ', get_the_excerpt(), $limit);

if (count($excerpt)>=$limit) {

array_pop($excerpt);

    $excerpt = implode(" ",$excerpt).'...';

  } else {

    $excerpt = implode(" ",$excerpt);

  }       

  $excerpt = preg_replace('`[[^]]*]`','',$excerpt);

return $excerpt;

}

 

function content($limit) {

  $content = explode(' ', get_the_content(), $limit);

if (count($content)>=$limit) {

array_pop($content);

    $content = implode(" ",$content).'...';

  } else {

    $content = implode(" ",$content);

  }       

  $content = preg_replace('/[.+]/','', $content);

  $content = apply_filters('the_content', $content);

  $content = str_replace(']]>', ']]>', $content);

return $content;

}

You should pay attention to the_excerpt() and the_content() segments. Write into the brackets the number of words you want to limit your excerpt to.

Here is an example: excerpt(30) – this means your excerpt will have at most 30 words. Add it to the the_content() in the same way.

Limit your WordPress Excerpt Length by the number of characters.

Sometimes you will lose accuracy by making the number of words the main criterion.. With shorter words, the text will be smaller and vice versa. This looks inconsistent and unprofessional.

Another solution is to change the criterion to the number of characters. In WordPress, all you have to do is to use the following code in the setting file of your theme, no matter if it’s a classic or child theme.

/**

 * Limit excerpt to a number of characters

 *

 * @param string $excerpt

 * @return string

 */

functioncustom_short_excerpt($excerpt){

            returnsubstr($excerpt, 0, 200);

}

add_filter('the_excerpt', 'custom_short_excerpt');

200 is the number you have to replace. Choose any other number of characters that suit your needs.

The main disadvantage of this function is that most of the time, your last word(s) may be trimmed when the text exceeds the limit. However, there is a solution.

You can calculate your words and characters exactly or, even simpler, use the following code segment, which will cancel the trimming function of the software.

/**

 * Limit excerpt to a number of characters without cutting last word

 *

 * @param string $excerpt

 * @return string

 */

functioncustom_short_excerpt($excerpt){

            $limit = 200;

 
            if (strlen($excerpt) > $limit) {

                        returnsubstr($excerpt, 0, strpos($excerpt, ' ', $limit));

            }
 

            return $excerpt;

}

 add_filter('the_excerpt', 'custom_short_excerpt');

Change excerpt length with filters

There is also an easier way for you to automatically change the excerpt length without editing each file. Instead of including and editing the_excerpt() function, you can use filters.

WordPress has a very efficient filter, called “excerpt_length”. In order to enable it, copy the following snippet into your functions.php file. Then change the “20” to the number of words to which you want to limit your excerpt.

add_filter( 'excerpt_length', function($length) {

return 20;

} );

Beforehand, set your theme to run the the_excerpt function. If you use a premium one, you don’t need to follow that step, because those themes are already prepared for the function.

If you struggle to make the function work properly, try contacting your developer. There are some nuances of the code and the function that may need particular assistance.

Let the plugins from WordPress change excerpt length

There is even a simpler method to change the excerpt length – the WordPress plugins. We’ve gathered some of the most efficient ones. Choose the one that fits your needs and let it do the job.

Best 4 plugins for changing WordPress excerpt length

Change Excerpt Length

 

It’s really easy to use this plugin. It changes the Settings by adding a new feature - Reading page for excerpt length, which is exactly what you need. Change the number of words and the work is done.

Custom Excerpt Length

 

This one works on the same principle – simplicity and efficiency. Check the Settings after installing the plugin and you’ll see the new option “Reading page”. Just set the number of words.

Advanced Excerpt

 

This plugin is a little more sophisticated. Apart from the basic option of changing the excerpt length, it allows you to add some more advanced functions. Check it out and see how it can improve the general display of your blog.

Excerpt Length

 

Excerpt Length is not only about length, despite its name. It also provides some other advanced options. From this point of view, it’s similar to the one presented above.

The final option

I'm interrupting the article to tell you about BeTheme, the definitive multipurpose theme. If trying to satisfy multiple clients has become more stressful than rewarding, BeTheme is the solution for that.

BeTheme’s selection of hundreds of customizable, responsive pre-built websites is the highlight and a proven stress reducer.

The customizability of the theme makes it a dream come true for its users. There are 4 types of Page Builders that you can use with it: WPBakery, BeBuilder, and Elementor among them.

And now with the Live Builder, it’s even more impressive.

Check out BeTheme and see why our users love it!

The rest of the article is down below.

 

If you’re not into code and you don’t want to permanently edit the files to fit, then don’t be discouraged. We have another option for you.

This last solution for making your excerpt attractive, is to manually edit the text. You can do it yourself or hire someone who knows how to handle words better than you. It’s not difficult to find good content and copywriters nowadays and means you won’t need any other tools or software programs. You can change it anytime if something doesn’t go well with the display.

FAQ on How To Edit The WordPress Excerpt Length

What is the default WordPress excerpt length?

The default excerpt length in WordPress is 55 words. This setting applies when using the_excerpt function in your WordPress templates. The CMS excerpt manipulation happens automatically for all post types unless you modify this through WordPress filters.

How do I change excerpt length without coding?

Install a plugin that handles post summary customization. Several WordPress plugins offer content preview configuration through the WordPress Admin Panel. Navigate to your plugin settings after installation to adjust the text preview length without touching any PHP code.

Where do I add the excerpt_length filter code?

Add the filter code to your child theme's functions.php file. This approach ensures your modifications remain intact during WordPress core updates. Access this file through the WordPress Theme Editor or via FTP for direct file editing.

Can I have different excerpt lengths for different pages?

Yes. Create conditional filters based on page templates or post types:

function custom_excerpt_length($length) {
    if (is_home()) {
        return 30;
    } elseif (is_archive()) {
        return 25;
    }
    return 55;
}
add_filter('excerpt_length', 'custom_excerpt_length');

How do I completely disable excerpts?

Return a zero-length value using the excerpt_length filter in your functions.php:

function disable_excerpts($length) {
    return 0;
}
add_filter('excerpt_length', 'disable_excerpts');

This WordPress development technique prevents any text preview from displaying in your template hierarchy.

Can I control the excerpt ending symbol?

Absolutely. Use the excerpt_more filter to modify the WordPress text shortening symbol:

function custom_excerpt_more($more) {
    return '... <a href="'.get_permalink().'">Read More</a>';
}
add_filter('excerpt_more', 'custom_excerpt_more');

Do excerpt changes affect manual excerpts?

No. Manual excerpts (added in the WordPress Dashboard excerpt box) override any automatic excerpt settings. Your custom excerpt_length filter only affects auto-generated content sample sizes when no manual excerpt exists.

How do I make excerpts show HTML formatting?

By default, the_excerpt strips HTML tags. Use a custom function with the_content instead:

function custom_formatted_excerpt() {
    $content = get_the_content();
    $content = apply_filters('the_content', $content);
    $content = wp_trim_words($content, 30, '...');
    echo $content;
}

Will changing excerpt length affect SEO?

Modifying excerpt length doesn't directly impact SEO rankings. However, well-crafted homepage post previews can improve user engagement metrics. Balance between providing enough context and keeping your archive page excerpts concise.

How can I display full post content instead of excerpts?

Replace the_excerpt() with the_content() in your WordPress template files (usually content.php). Alternatively, use the_content() with a custom "Read More" tag to control display excerpt limitation on your blog snippet settings.

Conclusion

Now you understand how to edit the WordPress excerpt length through multiple approaches. The WordPress hooks system provides flexibility for both beginners and advanced users to modify their post digest configuration.

Remember these key points:

  • Use the WordPress template hierarchy to implement your changes correctly
  • Test your content extract size on different devices
  • Keep your blog snippet settings consistent across your site
  • Consider how display excerpt limitation affects user experience

Small changes to your theme code editing can dramatically improve your archive page excerpts and frontend excerpt display. Whether you're working with the WordPress Customizer or diving into PHP excerpt modification, these content brief setting techniques give you control over how visitors experience your blog.

By taking time to configure your WordPress reading settings properly, you'll create a more engaging content preview that balances information with visual appeal. This simple WordPress development task delivers lasting improvements to your site's usability.

If you enjoyed reading this article on how to edit the WordPress excerpt length, you should check out this one about how to update PHP in WordPress.

We also wrote about a few related subjects like how to hide the page title in WordPress, how to add expires headers, how to set homepage in WordPress, how to remove query strings from static resources, how to backup a WordPress site, how to disable comments in WordPress and how to add excerpts to your pages in WordPress.

Albert Ślusarczyk
Albert Ślusarczyk
As the co-creator of Be Theme, I am a strong believer in designing with care and patience. I pour my energy, time & knowledge into perfecting the theme for our 260,000+ customers.
Siteground Hosting