How to Set Excerpt Length in WordPress (2 Different Methods)

Last updated on Feb 17, 2024

Excerpt is one of the elements you can maximize to increase the chances your article getting read by your visitors. It contains the keynote of what you want to convey through your article. The function of post excerpt is pretty similar to meta description in the SEO discussion. You can add a custom excerpt on the WordPress editor when you write or edit a post.

If you don’t add one, WordPress will automatically generate the excerpt from the beginning paragraph of your article. The length is varied depending on the theme you use. If you want to set custom length of post excerpt on your site, WordPress allows you to do so.

As we have just said above, the default length of post excerpt is varied depending on the theme you use. That said, the setting location to set the excerpt length lies on the theme customizer (Appearance -> Customize). However, it’s not always the case. On some themes (like Newspaper), you can set the post excerpt from the theme panel belongs to the theme.

Here are two ways to set the post excerpt length in WordPress

1. Via Theme Customizer

The most common way to set the post excerpt is via theme customizer. The precise setting location depends on the theme you use. You can access theme customizer by going to Appearance -> Customize on your WordPress dashboard. The theme we use on this example is Pagebuilder Framework.

To set the post excerpt length on Pagebuilder Framework theme, you can open the Blog -> General block on the theme customizer. Set the excerpt length on the Excerpt Length option. You can also replace the default excerpt indicator if you want it.

2. By Adding a New Function

Some themes — such as Hello and other minimalist themes — offer no setting option to set the excerpt length. If you use this sort of theme, you can set the excerpt length by adding a new function. To do so, first, go to Appearance -> Theme Editor on your WordPress dashboard. Select the functions.php file on the right panel to edit it.

Paste the following code right beneath the last line of the file content.

function custom_excerpt_length( $length ) {
	return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

You can replace the return value on the code above according to the excerpt length you want to set. Here is the example of the code placement:

Don’t forget to click the Update File after adding the code to update the file.

This page may contain affiliate links, which help support the project. Read our affiliate disclosure.

Editorial Staff

Save $178 per year

by switching to the best WordPress theme 👇🏻

new

Got WordPress Knowledge?

Why not turning it into profit? Learn how to turn your WordPress knowledge into profit blogging. FREE!

Where should we send the template?

Thanks! Please check your inbox to confirm.