Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Blogging & content · Guide

How to Get Excerpt in WordPress (Step by Step)

How to Get Excerpt in WordPress (Step by Step)

Short answer

To add an excerpt, open a post, find the Excerpt field in the post settings sidebar, type a summary and update. To display it, use the Post Excerpt block inside a Query Loop, or call the_excerpt or get_the_excerpt in a PHP template. Without a manual excerpt, WordPress uses the first 55 words.

Key takeaways

  • Write custom excerpts in the post settings sidebar of the block editor.
  • Pages need add_post_type_support to get an excerpt field.
  • Use the Post Excerpt block in a Query Loop to show excerpts with blocks.
  • the_excerpt prints the excerpt; get_the_excerpt returns it as a value.
  • excerpt_length and excerpt_more only change automatic excerpts.

What is an excerpt in WordPress?

An excerpt is a short summary of a post that WordPress shows on blog pages, archives, search results and feeds instead of the full article.

You can write one yourself, or WordPress builds one automatically from the first part of the post. A hand-written excerpt is usually better, because it reads like a summary instead of a cut-off sentence.

There are two sides to getting an excerpt. One is adding the excerpt in the editor. The other is displaying it on your site, either with blocks or with PHP in a theme.

TaskWhereMethod
Write a custom excerptBlock editor sidebarExcerpt field
Show excerpts in a listSite Editor or pagePost Excerpt block in a Query Loop
Show excerpt in a PHP templateTheme filethe_excerpt()
Get excerpt as a valuePHP codeget_the_excerpt()
Change automatic lengthPHP codeexcerpt_length filter
Enable excerpts on pagesPHP codeadd_post_type_support()

How do you add a custom excerpt to a post?

Open the post in the block editor, find the Excerpt field in the post settings sidebar, type your summary and update the post.

Here are the steps:

  1. Go to Posts and open the post you want to edit.
  2. Make sure the right sidebar shows the Post tab, not the Block tab.
  3. Find the excerpt area. In recent WordPress versions it appears near the featured image as an excerpt link or field.
  4. Type a summary of one or two sentences.
  5. Click Save or Update.

Keep it short and specific. A good excerpt tells readers what the post answers, so they know whether to click.

If you use the classic editor, the Excerpt box sits below the content area. If it is missing there, open Screen Options at the top right and tick Excerpt.

Why can you not find the excerpt field?

The excerpt field is missing when the panel is turned off in editor preferences, or when the post type, such as pages, does not support excerpts.

In the block editor, open the three dot menu at the top right and choose Preferences. Look under the panels settings and switch the excerpt panel on.

Pages do not support excerpts by default in WordPress. Custom post types only support them when the code that registers them includes excerpt support.

To add excerpts to pages, use add_post_type_support() in a child theme or a snippets plugin:

add_action( 'init', function () {
    add_post_type_support( 'page', 'excerpt' );
} );

Reload the page editor after adding it and the excerpt field appears. If you are new to adding code, use a child theme so a theme update does not remove it.

How do you show excerpts with blocks?

In a block theme or any page, use a Query Loop block with a Post Excerpt block inside it, and each post in the list shows its excerpt.

Most blog and archive templates in block themes already include this. To check or change it:

  1. Go to Appearance > Editor and open Templates.
  2. Open the Blog Home or Index template.
  3. Select the Query Loop block and look inside its Post Template.
  4. Add a Post Excerpt block if it is not there, or select the existing one.
  5. Adjust its settings, such as the Read more link text and word count.

If the template uses a Post Content block instead, it shows full posts. Swap it for Post Excerpt to show summaries.

Our guide to what a block theme is explains templates and the Site Editor if this area is new to you.

How do you get the excerpt with PHP?

Use the_excerpt() to print the excerpt inside the loop, or get_the_excerpt() to return it as a value you can store, change or print later.

The two functions do similar jobs in different ways. the_excerpt() echoes the excerpt wrapped in paragraph tags. get_the_excerpt() returns plain text without printing anything.

Inside a standard loop in a classic theme template:

while ( have_posts() ) {
    the_post();
    the_title( '<h2>', '</h2>' );
    the_excerpt();
}

To get the excerpt of a specific post, pass its ID or post object:

$summary = get_the_excerpt( 42 );
echo esc_html( $summary );

Escape the value when you print it yourself. That keeps any stray markup from breaking the page.

If a template edit shows a blank page or an error, turn on debug mode to see the exact message. Edit theme files on a staging copy first whenever you can.

How do you check if a post has a custom excerpt?

Use has_excerpt(), which returns true only when someone wrote a manual excerpt, so you can show it and fall back to something else when it is empty.

This is useful when you want manual excerpts in one place but not automatic ones. For example, you might show a summary box only when an author wrote one.

if ( has_excerpt() ) {
    echo '<p class="summary">' . esc_html( get_the_excerpt() ) . '</p>';
}

The has_excerpt() reference lists its arguments, including a post ID for use outside the loop.

How does WordPress create an automatic excerpt?

When no manual excerpt exists, WordPress strips tags and shortcodes from the content and takes the first 55 words, then adds an ellipsis or read more text.

The cut can land mid-sentence. That is why automatic excerpts sometimes look awkward on archive pages.

If a post has a More block, some classic themes use the content before it as the teaser on archive pages. That works with the_content(), not with the_excerpt(), so the two systems can confuse each other.

How do you change the excerpt length?

Use the excerpt_length filter to change the automatic word count, and the excerpt_more filter to change the text added at the end.

Both filters only affect automatic excerpts. Manual excerpts are always shown in full, whatever length you set.

add_filter( 'excerpt_length', function () {
    return 30;
}, 999 );

add_filter( 'excerpt_more', function () {
    return '&hellip;';
} );

The excerpt_length hook and excerpt_more hook pages show the defaults.

The high priority of 999 helps your value win over a theme that sets its own length. In block themes, the Post Excerpt block also has its own word count setting, which is often simpler.

For a fixed length from any text, wp_trim_words() trims a string to a word count. It is handy for custom fields or descriptions that are not post excerpts.

Is the excerpt the same as the meta description?

No, the excerpt is shown on your own site, while the meta description is a hidden tag that search engines may use for the snippet in results.

The meta description lives in the page head as a meta name tag. Search engines decide whether to use it. Google explains this in its snippet documentation.

Some SEO plugins fall back to the excerpt when no meta description is set. Writing both separately gives you more control.

Do feeds use the excerpt?

Yes, if your Reading settings tell WordPress to show excerpts in feeds, RSS readers and email tools that use your feed receive the excerpt instead of the full post.

Go to Settings > Reading and find the option for how each post appears in a feed. The Reading Settings documentation explains each choice.

Showing excerpts in feeds sends readers to your site to finish the article. Showing full text is friendlier for feed readers.

How do you get the excerpt through the REST API?

The WordPress REST API includes the excerpt in every post response, so headless front ends and apps can read it without extra code.

Request a post from the posts endpoint, such as /wp-json/wp/v2/posts, and look for the excerpt field. Its rendered value holds the excerpt as HTML, ready to display.

The API returns the manual excerpt when one exists, and an automatic one when it does not. The same length filters apply, so a change to excerpt_length also changes the API output.

If you only need a few fields, add the _fields parameter to the request. That keeps responses small, which helps when you load many posts at once.

What makes a good excerpt?

A good excerpt is one or two plain sentences that state what the post covers and why it helps, without repeating the title word for word.

Tips that work well:

  • Aim for roughly 20 to 40 words.
  • Lead with the answer or benefit, not background.
  • Avoid links and formatting, which some templates strip.
  • Write it after the post, when you know what it actually covers.

When you refresh older content, update the excerpt too. Our guide on updating old posts for SEO covers what else to review.

Frequently asked questions

How long is the default WordPress excerpt?

The automatic excerpt is 55 words by default. WordPress strips tags and shortcodes from the post content, takes the first 55 words and adds a trailing ellipsis. You can change the number with the excerpt_length filter or the Post Excerpt block setting.

Why is my custom excerpt length setting ignored?

Length settings only trim automatic excerpts. If you wrote a manual excerpt, WordPress shows it in full. Shorten the manual excerpt itself, or trim it in your template with a word trimming function if you need a hard limit.

Can pages have excerpts in WordPress?

Not by default. Add excerpt support to pages with a small snippet using add_post_type_support in a child theme or code snippets plugin. After that, the excerpt field appears when you edit a page.

What is the difference between the_excerpt and get_the_excerpt?

the_excerpt prints the excerpt straight to the page, wrapped in paragraph tags. get_the_excerpt returns the text without printing it, so you can store it, change it, or print it yourself with your own markup and escaping.

Does the excerpt help SEO?

Indirectly. Excerpts improve archive pages and give readers a reason to click. Some SEO plugins use the excerpt when no meta description exists, but writing a dedicated meta description gives you more control over search snippets.

Sources

  1. the_excerpt() WordPress Developer Resources
  2. get_the_excerpt() WordPress Developer Resources
  3. excerpt_length hook WordPress Developer Resources
  4. add_post_type_support() WordPress Developer Resources
  5. Settings Reading Screen WordPress.org
  6. Control your snippets in search results Google Search Central

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.