In WordPress Customize Excerpt length means changing the summary of an article or post, formed by a predefined number of words and often visible in the Archive, Category or Tag views.

How the Excerpt works

WordPress‘s except helps to create a preview of the content you want to include so that users’ attention is drawn to the content itself. In WordPress customize the length of the Excerpt present in this summary or even enter it manually bypassing the automatic detection of the first n words.

WARNING. The steps below should be performed by experienced people as they are potentially dangerous and could damage the server. If you do not know what you are doing you can request a free quote.

Customizing the length of the Excerpt

Edit the wp-content/themes/YOUR_THEME/functions.php file of the WordPress theme you selected by adding this code:

function my_excerpt_length($length) {
    return 20;
}

add_filter(‘excerpt_length’, ‘my_excerpt_length’);

It is also possible to customize the length of the summary only in some specific cases:

function my_excerpt_length($length) {

    if(is_home() || is_category() || is_archive() ) {
        return 20;
    }
}

add_filter(‘excerpt_length’, ‘my_excerpt_length’);

where:

  • is_home(): checks whether the current page is the homepage
  • is_category(): checks whether the current page is a category
  • is_archive(): checks whether the current page is an archive

Manually enter the Excerpt

It is also possible to have the Excerpt inserted manually for example to avoid cutting important concepts by simply activating the hidden feature from the WordPress interface.

  1. From the article interface, click on the “Screen Settings” button in the upper right corner.

    Customizing the length of the Excerpt

  2. Select the checkbox labeled “Summary”

    MANUALLY ENTER THE EXCERPT

Wordpress Site Update Quote

    Contact us for a free quote