How to Customize the Excerpt Length in WordPress

An excerpt is a part of a post that links to the full article. Can you change the length of a WordPress excerpt? The short answer is “Yes“. You can customize the excerpt length.

WordPress is a powerful and versatile content management system that allows users to customize the excerpt length of their posts. The excerpt length determines how many words are displayed in the post summary that appears in the blog list, search results, and other areas. This feature can be used to optimize the way content is presented and increase user engagement.

In the blog section, most of the WordPress themes display a part of the content of the post. By default, the the_exerpt() function displays 55 words of the content. But what if you wanted to show more or less than 55 words for your post excerpts?

In WordPress, the excerpt can be found in various parts of the structure of the theme, including:

  • RSS Feeds
  • Search Results
  • Tag Archives
  • Category Archives
  • Monthly Archives
  • Author Archives

To decrease or increase this length, add the below code to the “functions.php” file of your theme.

Once the code has been added, the excerpt length will be changed to 50 words. It is important to note that the excerpt length should not be set too high, as it can affect the readability of the post summary.

if (!function_exists('hs_alter_excerpt')) :
     * Filter to change excerpt length size
    function hs_alter_excerpt($length)
        if (is_admin()) {
            return $length;

        return 50;
    add_filter('excerpt_length', 'hs_alter_excerpt');

In code as you can see it will return 50 that is 50 words of the content. By changing 50 to any number you desire, WordPress will show the post content with the given number of words.

Customize the excerpt length with the plugin

If you do not prefer to edit the theme’s files then you always have an option to use the plugins, which does the job for you. For changing the excerpt length we have a plugin called advanced excerpt, which provides the feature to customize the excerpt length along with a few more advanced features, which makes your post excerpts look attractive.