Skip to content
Development

Hide the WordPress excerpt when it is empty

Stop WordPress inventing an excerpt from the first 55 words, change its length, and show an excerpt only when an editor wrote one.

By WP24×7 engineers4 min readPublished September 29, 2009Updated November 29, 2026

At a glance

If you leave a post's excerpt field empty, WordPress still builds a summary from the first 55 words of the content. To show an excerpt only when an editor wrote one, check has_excerpt() in the template, or remove the wp_trim_excerpt filter to stop automatic excerpts site wide. This guide covers both, plus length, ending, fallbacks, block themes and the side effects to test.

Updated November 29, 2026 · For WordPress theme developers and editors

  • For developers and editors who do not want automatic excerpts
  • Targeted fix wrap the_excerpt() in an has_excerpt() check in a child theme template
  • Site-wide fix remove the wp_trim_excerpt filter, then test feeds, search and SEO output
  • Length excerpt_length filter counts words, 55 by default
  • Block themes adjust the Post Excerpt block and test with empty excerpts
  • Safe working use a child theme and take a backup before editing templates

If you leave a post's excerpt field empty, WordPress still shows a summary, built from the first 55 words of the content. To show an excerpt only when an editor wrote one, check `has_excerpt()` in the template, or remove the trimming filter if you want it site wide.

What does WordPress do by default?

the_excerpt() prints the excerpt field if it has content. If it is empty, WordPress builds a teaser by stripping shortcodes and tags from the content and trimming to 55 words, then adds […]. That helps on a blog and annoys you when the start of a post makes a poor summary, such as a page that opens with a form, a quote or a heading.

How do I hide empty excerpts?

In your child theme's template, show the excerpt only if one was written:

if ( has_excerpt() ) {
	the_excerpt();
}

This touches one template and changes nothing else, so it is the first choice in a classic theme.

What side effects does the site-wide fix have?

AreaEffect
RSS feeds that use excerptsEmpty descriptions for posts with no excerpt
Search and archive pagesMay look empty or show blank space
SEO pluginsMay use the excerpt as a meta description fallback, with their own trimming logic
Block themesPost Excerpt behavior depends on the WordPress version

Because of those effects, the template check is safer for most sites.

How do I change the length and ending?

Use the excerpt_length filter. It is a word count:

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

The high priority makes your value win over a theme's own. The […] ending can be changed with excerpt_more, covered in changing the Read More link:

add_filter( 'excerpt_more', function () {
	return '…';
} );

How do I show a fallback instead of nothing?

Often you want a deliberate fallback rather than an unpredictable trim:

if ( has_excerpt() ) {
	the_excerpt();
} else {
	echo '<p>' . esc_html( wp_trim_words( get_the_title() . '. ' . wp_strip_all_tags( get_the_content() ), 20, '&hellip;' ) ) . '</p>';
}

Or skip the fallback and let the card show only the title and image. wp_trim_words() lets you choose the number of words and the ending, and works on any text you pass it. Use get_the_content() with care in templates, as it returns the raw content without filters applied.

Which approach fits which site?

SituationApproach
Classic theme, some posts need summarieshas_excerpt() check in the template
You never want automatic excerpts anywhereRemove wp_trim_excerpt, then test feeds, search and SEO output
Shorter or longer automatic excerptsexcerpt_length filter
Block themeEdit the template in the Site Editor, adjust the Post Excerpt block
An excerpt shown only when an editor wrote one

When should I write excerpts by hand?

For posts that appear in lists, search results and social shares, a written excerpt of one or two sentences is usually better than a trimmed opening. The excerpt field is hidden by default in the block editor: open Settings (the gear icon), then the post sidebar's Excerpt panel. An excerpt is not a meta description, though they overlap; SEO plugins let you write a separate description and fall back to the excerpt or the start of the content when it is empty. An empty description tag is usually better than an irrelevant one, but a sentence you wrote is better than both. Short, written excerpts that stand on their own also help list pages stay scannable and accessible.

A common scenario

An events site lists upcoming events and each event page starts with a long registration form. The automatic excerpt trims form labels into the list page, which reads as nonsense, and the editors do not want to write 200 excerpts. A reasonable plan is the has_excerpt() check in the events archive template, with event title, date and location shown instead, and excerpts written only for the handful of featured events.

How do I check the result?

  1. Create one post with an excerpt and one without.

  2. View the blog page, an archive, search results and the RSS feed.

  3. Check how a shared link preview looks, since some previews use the excerpt.

  4. Look at the page source for the meta description your SEO plugin prints.

What mistakes should I avoid?

  • Removing wp_trim_excerpt and forgetting that feeds and SEO output also lose their fallback.
  • Editing the parent theme, where an update erases the change.
  • Using get_the_excerpt() inside a custom query without setup_postdata(), and getting the wrong post's text.
  • Setting excerpt_length at default priority, where a theme overrides it.
  • Forgetting that page caches keep serving the old output.
Theme summaries you cannot control?

A custom template is usually a short job.

FAQ

Questions people ask

12 answers. Can't find yours? Ask an engineer.

Why does WordPress show text when I left the excerpt empty?

When no excerpt is stored, get_the_excerpt() builds one by trimming the post content to about 55 words. That is built-in behavior.

Link to this answer
What is the safest way to hide empty excerpts?

In a classic theme template, check has_excerpt() before calling the_excerpt(). It changes only that template and does not alter feeds or other parts of the site.

Link to this answer
Does the excerpt length setting count characters?

It counts words, by default 55. For languages written without spaces, WordPress counts characters instead. Change it with the excerpt_length filter at a high priority so your value wins over the theme's own.

Link to this answer
What happens to RSS feeds if I remove the automatic excerpt?

Feeds that use excerpts will show empty descriptions for posts with no stored excerpt. Search and archive pages in your theme may also look empty.

Link to this answer
How do I change the excerpt length?

Use the excerpt_length filter with a high priority such as 999 so your value wins over a theme's own. In a block theme the Post Excerpt block has its own length setting.

Link to this answer
How do I change the [...] ending?

Use the excerpt_more filter to return your own ending, such as an ellipsis. The Read More link guide covers it in detail, including how block themes handle the ending differently.

Link to this answer
Where is the excerpt field in the block editor?

It is hidden by default. Open Settings, then the post sidebar's Excerpt panel. For pages it appears only if your theme or a plugin adds excerpt support to pages.

Link to this answer
Is an excerpt the same as a meta description?

No, though they often overlap. SEO plugins let you write a separate description and fall back to the excerpt or the start of the content when it is empty. Check the page source for a post with neither.

Link to this answer
Can I show a deliberate fallback instead of nothing?

Yes. Use wp_trim_words with a length and ending you choose, or show only the title and image on the card. Use get_the_content with care, as it returns raw content without filters.

Link to this answer
Why does get_the_excerpt show the wrong post in my custom query?

Using it inside a custom query without setup_postdata() can return the wrong post's text, because WordPress is still pointing at the global post. Call setup_postdata() and wp_reset_postdata() around the loop.

Link to this answer
Do block themes behave the same way?

The Post Excerpt block reads the excerpt through WordPress, but how it behaves when the excerpt is empty depends on the WordPress version. Test it in the Site Editor and do not rely on the filter alone.

Link to this answer
Can you change this for me?

Yes. If a theme shows summaries in a way you cannot control, a custom template is usually a short job for our WordPress development team.

Link to this answer

Keep reading

Want an engineer on it?

Tell us what is wrong in plain words. A person reads it, today.