Skip to main content

How to Change The Default Excerpt Length In WordPress

WordPress excerpts provide a way to show a teaser of a post’s content on the blog’s home page and archive pages. The excerpt is automatically generated based on the first 55 words of the post, but you can change this length by using a plugin or by editing the code.

In this article, we will show you how to change the default excerpt length in WordPress programmatically.

Why Change the Default Excerpt Length?

The default 55-word length is arbitrary and may not be ideal for all sites. For example, if you are running a news website, then shorter excerpts with headlines might work better. On the other hand, if you are running a tutorial blog, then longer excerpts might be more useful.

It really depends on what type of content you write and what style your site is in. Some themes also come with their own excerpt-length settings.

If you want more control over how your excerpts look, then it is best to change the default excerpt length in WordPress. This way you can have shorter or longer post summaries without affecting the actual post content.

How to Change the Excerpt Length Programmatically

Insert this snippet of PHP into your functions.php file:

//change excerpt lenth to 100 characters
add_filter( 'excerpt_length', function($length) {
    return 100;

By continuing to use the site, you agree to the use of cookies.