HostPapa Explains: WordPress Excerpt

A WordPress excerpt is a summary of a long article, and it is normally used as an alternative to displaying the full content of a post on the blog index and archives. 

Displaying a full article is not practical. With excerpts, you can only show short summaries:

Will My Theme Display Excerpts?

WordPress includes a built-in functionality for excerpts, but we cannot assure you that your theme displays excerpts this depends on the theme developer. 

However, later we’ll tell you about a method that may force your theme to show excerpts. 

Generating WordPress Excerpts

There are two ways to generate excerpts in WordPress: 

  1. By default: WordPress generates excerpts automatically using the first 55 words of the post. 
  2. Manually: You can edit the text you want to use for the post’s excerpt with a small adjustment. This method has the advantage of not limiting the excerpt to the first part of the post, you could write a summary if you needed to. 

Manual Excerpts in WordPress 

You can enable manual excerpts with the WordPress Editor, you just need to create a new post like you normally would. 

Go to Posts>>Add New and navigate through the right-hand side menu to find the Excerpt box. 

Adding your own manual excerpt here won’t affect your normal post content, just the excerpt that your theme generates automatically. 

Making Your Theme Display Excerpts

As we pointed out before, some themes give you the option of displaying excerpts on the index pages of your blog. 

You can usually see these options in the WordPress customizer or in the custom theme settings panel. 

You can force your theme to use excerpts by manually editing template files if your theme doesn’t offer the option of excerpts. This is an advanced method, if you don’t feel comfortable editing your template files manually, try using another theme or buying a pro version. 

Editing a Theme’s Code to Display Excerpts

Please note that these instructions may not apply to all themes. Some themes break their code into many parts, and if you don’t have a basic understanding of the WordPress loop, you might find it difficult. 

Before you edit anything, make sure you have backed up your site and that you’re using a WordPress child theme so that you don’t overwrite any changes. 

After that, go to Appearance>>Theme Editor. There we can start editing the following  files:

  • Index.php
  • Archive.php
  • Category.php

Find the code snippet:

<?php the_content(); ?>

And replace that snippet with this one:

<?php the_excerpt(); ?>

Don’t forget to save your changes! 

If you don’t see the_content() or if you don’t even see these files at all, you should ask a professional for help. 

Manually Changing the Length of Excerpts

You can change the length of excerpts by using excerpt_length filter in the functions.php file in your child theme. This is one of the codes you can add to functions.php (change number 25 for the number of words you want your excerpts to show):

/**

* Filter the excerpt length to 20 words.

*

* @param int $length Excerpt length.

* @return int (Maybe) modified excerpt length.

*/

function wpdocs_custom_excerpt_length( $length ) {

return 25;

}

add_filter( ‘excerpt_length’, ‘wpdocs_custom_excerpt_length’, 999 );

Enabling Excerpts for WordPress RSS Feed

If someone subscribes to your RSS feed, they will access your entire post via RSS. But if you’d rather only give them just the excerpt, you can do so from your WordPress dashboard. Go to Settings>>Reading. Locate the For each article in a feed option, and check the Summary box. Don’t forget to save your changes!

Using the “More” Tag Instead of Excerpts

Don’t confuse the “More” tag with an excerpt. The “More” tag is a part of the WordPress Editor toolbar, and WordPress actually considers it a teaser instead of an excerpt. 

The “More” tag works similarly to an excerpt in terms of end results. It also has an advantage: it will let you display a summary without changing your theme’s files. The disadvantage is that it will only let you use the first part of the post. 

In the post editor, use the “More” tag by clicking on the “+” icon of a new content block, scroll to Layout Elements and select the More option:

You will see a representation of the “More” tag, like this:

WordPress will only show the content before the “More” tag on your index pages, but each individual blog page will show the whole text, including the text before the tag. 

 

For further questions, or if you need any help, please open a support ticket from your HostPapa Dashboard. Click here to learn how.

 

Was this article helpful?

  • Was this article helpful ?

  • yes   no

Related Articles

Leave A Comment?