Home > Help Center > Applications > WordPress > WordPress Excerpts

WordPress Excerpts

You've probably noticed how news sites post a short description of an event on the homepage and add a link to the entire article.

WordPress Excerpt is exactly the same feature that lets you post a short description of the post with a link to the entire post:

WordPress excerpt example

The entire article

The excerpt is used to replace the full content in RSS feeds when the option to display summaries is selected in Dashboard > Settings > Reading.

Depending on the WordPress theme, the excerpt can be displayed in places where quick summaries are preferable to full content such as search results and all types of archives.

Excerpt, Automatic excerpt, and Teaser

The manual WordPress excerpt is often confused with the automatic excerpt or with the teaser (the part of a post that appears on the front page when you use the More tag). While both are related to the manual excerpt, they are different from it.

The relationship between the three is this:

When the post template uses the the_content() template tag, WordPress will look for the More tag and create a teaser from the content that precedes the More tag:

Article teaser with More tag

When a post has no manual excerpt and the post template uses the the_excerpt() template tag, WordPress generates an excerpt automatically by selecting the first 55 words of the post:

Article excerpt from the first 55 words

How to add excerpts to posts

The Excerpt text field is hidden by default on Post and Page edit screens. To make it visible click Screen Options and select the box in front of the Excerpt label:

Excerpt box in the Screen Options panel

A new text field Excerpt will appear below the text editor where you must enter the excerpt content. An excerpt can be as short or as long as you wish. If adding the excerpt manually, you may use (some) HTML formatting and the tags will not be stripped.

Excerpt text field below the editor

How to add a link beneath an excerpt to the full post

When using the excerpt feature WordPress does not automatically provide a link to a page containing the full post. To generate a link include the following code in the loop directly below :

 Read More...

Or put the following in your theme's functions.php:

function new_excerpt_more( $more ) {
  return ' ' . __('Read More', 'your-text-domain') . '';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );

This link will not appear on a new line. To achieve this, modify the CSS for the .read-more class.

If the template code automatically generates Continue reading link you must use conditional logic (if / else) to define that your link should appear only if the excerpt is provided otherwise you'll get two links below posts where the excerpt is missing:

Use conditional logic to manage the links

Control Excerpt Length using Filters

By default, excerpt length is set to 55 words. To change excerpt length to 12 words using the excerpt_length filter, add the following code to the functions.php file in your theme:

function wpdocs_custom_excerpt_length( $length ) {
    return 12;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );

Control the excerpt length with script

Managing the Excerpts

In order to get the most out of the WordPress capabilities to manage the excerpts, you need to have good knowledge of the WordPress template hierarchy and the use of basic functions such as get_template_part() in this case.

In the twentyseventeen theme manual excerpts are not enabled by default.

In the main template file index.php the below code defines how the content will be displayed:

get_template_part( 'template-parts/post/content', get_post_format() );

Understanding the WordPress template hierarchy this means that in the folder template-parts/post/ there will be a file named content-__.php (__ stands for postformattype) which will be used to display the content.

There is a file content-excerpt.php, but there is no post format excerpt. So how we can use this file for the content template?

We need to modify the code in the index.php file to this:

get_template_part( 'template-parts/post/content', 'excerpt' );

Conclusion

The smart use of excerpts is important for both readers and search engines.

If the excerpt wakes up the interest of readers, they will click the link to the entire article where you have also placed your affiliate links.

The description should contain the main keyword phrase for the article to be correctly indexed by the search engines.

Still not finding what you're looking for?

Contact our support team with any additional questions or concerns.

Contact support