# Hide the WordPress excerpt when it is empty

URL: https://wp24x7.com/how-to-remove-excerpt-if-left-empty/
Updated: 2026-11-29
Type: blog post
Audience: WordPress theme developers and editors

> 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.

## Key facts

- 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.**

> **Quick answer**
In a classic theme, wrap `the_excerpt()` in `if ( has_excerpt() )` inside a child theme template. Back up first, and edit by SFTP in a child theme, not in the dashboard's theme editor.

## 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?

### One template (safest)
In your [child theme's](/how-to-properly-set-up-child-theme) template, show the excerpt only if one was written:

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

This touches one template and changes nothing else, so it is the first choice in a classic theme.
### Site wide
WordPress builds the automatic excerpt in a function attached to the `get_the_excerpt` filter. Removing it stops the trimming everywhere:

```php
add_action( 'init', function () {
	remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
} );
```

After this, posts with no excerpt return an empty string. Check the side effects below.
### Block theme
Edit the template in the Site Editor, adjust the Post Excerpt block, and test with empty excerpts. Behavior with an empty excerpt depends on the WordPress version, so do not rely on the filter alone.

## What side effects does the site-wide fix have?

| Area | Effect |
|:--|:--|
| RSS feeds that use excerpts | Empty descriptions for posts with no excerpt |
| Search and archive pages | May look empty or show blank space |
| SEO plugins | May use the excerpt as a meta description fallback, with their own trimming logic |
| Block themes | Post 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:

```php
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](/how-to-change-the-read-more-link):

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

## How do I show a fallback instead of nothing?

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

```php
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?

| Situation | Approach |
|:--|:--|
| Classic theme, some posts need summaries | `has_excerpt()` check in the template |
| You never want automatic excerpts anywhere | Remove `wp_trim_excerpt`, then test feeds, search and SEO output |
| Shorter or longer automatic excerpts | `excerpt_length` filter |
| Block theme | Edit 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.
[WordPress development](/wordpress-development)
[Theme development](/wordpress-theme-development)

## Frequently asked questions

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.

### 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.
