How to Customize the Excerpt Length in WordPress

Used before category names. Blog WordPress WordPress Development

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.

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.

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 given number words.

Customize the excerpt length with 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.