How to add an Excerpt to WordPress Posts, Pages & Custom Post Types

If you want to add (and display) the excerpt in your posts, pages, or post types– you’ve come to the right place.

This step-by-step guide will teach:

  1. The basics of the WordPress Excerpt field
  2. Using the Excerpt for Posts
  3. How to enable Excerpts for Pages
  4. How to use Excerpts w/ Custom Post Types
  5. How to display the excerpt in your theme

WordPress Excerpts: the basics

What is the excerpt?

The excerpt is a core WordPress feature that is enabled by default on all pages. It’s a simple text-based field that is typically used to provide a summary or ‘hook’ for each blog post.

Adding an excerpt to each post is completely optional, but many themes will display it either on your single post template or archive loops (or both). And if you don’t use an SEO plugin (Yoast SEO, Rankmath, etc) many themes use the excerpt as your meta-description tag.

Which WordPress post types support excerpts?

By default, only Posts have built-in support for excerpts.

But WordPress is infinitely flexible and you can easily add excerpt support for Pages, WooCommerce Products or any other custom post type.

Where is the excerpt displayed?

Your theme controls where and when the excerpt is displayed, and it’ll be a bit different for every WordPress site.

Two common locations where the excerpt is displayed

  1. Inside the loop for each post on your archive/blog pages
  2. At the top of your single posts (often under the post title)

But you’re not limited to your theme’s default. If you’re willing to get your hands dirty, you can display the excerpt almost anywhere on your site with just one line of php code.

Don’t worry, I’ll show you how to Display The Excerpt in just a minute.

How to add the Excerpt to WordPress Posts

Excerpts are enabled on the Posts post type by default, but it may be hidden depending on your site’s settings. Here’s how to add (or edit) the excerpt on posts in both the Gutenberg Editor and Classic Editor.

Add Excerpt in the Gutenberg block editor

Excerpts are already enabled in Gutenberg posts. You just need to know where to look.

From the editor view, follow these steps:

  1. Click the settings cog in the top right corner
  2. Go to the Post settings tab of the settings menu (not Block settings)
Post settings tab in the Gutenberg editor view
  1. Scroll down and look for Excerpt (it’s right under the Featured Image)
  2. The Excerpt may be collapsed by default so click the label to expand
Add a post excerpt in Gutenberg editor

How to add the Excerpt in Classic Editor Posts

If you’re still using the Classic Editor for your content, the process is a little bit different.

Go to any existing classic editor post or create a new one from Dashboard > Posts > Add New

First, you’ll likely need to enable the Excerpt field before you can actually edit it.

  1. Click Screen Options in the top-right corner
Screen options menu in classic editor
Go to the Screen Options (top-right)
  1. Enable Excerpt under the Screen Elements settings
Enable the Excerpt screen element (Classic Editor)
Enable the Excerpt element (check the box)
  1. Now you can edit the Excerpt via the meta field which appears below the main content in your editor view.
Edit the excerpt field in the Classic Editor

How to add Excerpts to Pages

Pages are just another post type in WordPress, but they don’t support all the same features as Posts (at least not by default). For example, Pages don’t support Authors, Categories or Excerpts.

But fear not. You can enable excerpts for your pages with a single line of PHP.

Go to your theme’s functions.php file and add the following line of code:

add_post_type_support( 'page', 'excerpt' );

Note: There are other places you could add this code, such as a Code Snippets plugin or your very own Custom Functionality Plugin (advanced)

Adding Excerpts to Custom Post Types

Adding excerpt support to your custom post types (CPTs) is easy. The process is a bit different depending on whether you’ve created the post type yourself or are modifying someone else’s post type (e.g. from a plugin).

When you create the post type

When registering a post type in WordPress, you pass a number of arguments in your registration function, including which WordPress features it should support. One of those options is ‘Excerpt’. So just make sure that you add ‘excerpt’ to your php function:

'supports' => array('title','thumbnail','editor','page-attributes','excerpt'),

A complete example can be array(‘title’,’thumbnail’,’editor’,’page-attributes’,’excerpt’),” target=”_blank” rel=”noreferrer noopener”>found here.

Add the excerpt to 3rd-party post types

If your custom post type was created by a theme or plugin, you can still add the excerpt using the same technique we used for Pages.

Is your post type’s slug is your-post-type

The add the following code to your functions.php (replace the example slug with the real one)

add_post_type_support( 'your-post-type', 'excerpt' );

How to display the Excerpt in your theme

Adding a custom excerpt to your posts (and other post types) is only half the battle. That’s because it’s still up to your Theme where and how your excerpt will be displayed.

Fortunately, many themes give you some code-free control over excerpts.

But if you don’t like how your theme handles excerpts, you’ll need to take matters into your own hands (requires PHP).

Excerpt settings in your theme

Many pro themes (and some free ones) will let you choose whether to display the post excerpt on your blog page or taxonomy archives.

For example, popular themes like Astra, GeneratePress, Genesis and OceanWP all have this option. You’ll typically find the setting in the Customizer. Look for a section labelled Blog or Archives.

For example, here’s the Excerpt settings in GeneratePress Theme.

Display the excerpt in GeneratePress blog and archive pages

Adding the_excerpt() with PHP

If your theme doesn’t display the excerpt (or you want more control over how it is displayed) you’ll need to use some PHP to edit your theme’s template files.

Fortunately, WordPress does most of the heavy lifting automatically, providing handy function called the_excerpt() which will output your post’s excerpt whenever you choose.

Before we start: It’s always recommended to use a child theme rather than editing theme templates directly (you don’t want them to get overwritten next time there’s an update).

For example, lets say we want to edit the twenty-twentyone theme to display the excerpt on our single posts, just below the post title.

We’d open the content-single.php file which controls the content template for single posts and pages. The relevant section look like this:

<?php
/**
 * Template part for displaying posts
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package WordPress
 * @subpackage Twenty_Twenty_One
 * @since 1.0.0
 */

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

	<header class="entry-header alignwide">
		<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
		<?php twenty_twenty_one_post_thumbnail(); ?>
	</header>

	<div class="entry-content">
		<?php
		the_content();

First, you would want to copy this file to your child theme, making sure the file structure matches that of the parent theme.

Then to add the excerpt, all we need to do is add a smidgen of PHP to the template.

<header class="entry-header alignwide">
		<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
  		<p class="post-excerpt"><?php the_excerpt(); ?></p> 	
		<?php twenty_twenty_one_post_thumbnail(); ?>
 </header>

It’s just a single line of HTML with a bit of PHP. And it’ll output the post’s excerpt inside a paragraph tag, just below the <h1> post title.

Summary

The excerpt is a handy WordPress feature that can be used with almost any post type. By default it’s limited to posts, but you can use the add_post_type_support function to enable excerpts on any post type or page.

Your theme controls where (or if) the excerpt is displayed. Most often your theme will display the excerpt in two places:

  1. Inside the post loop on archive/blog pages
  2. At the top of your posts (not common)

But you can manually insert the excerpt into your templates with one line of php, to class up your intros and grab your visitors with a powerful hook.

Additional Resources:

Leave a Comment