The length of an archive’s description (the excerpt) and its “read more” wording can be changed with two filters or one line in a template. Choosing by purpose is quickest.
- You want it consistent site-wide →
excerpt_length/excerpt_moreinfunctions.php - You want to change just this one list →
wp_trim_words()in the template
First, the difference between two functions
<?php the_excerpt(); ?> <!-- outputs with <p>…</p> around it -->
<?php echo esc_html(get_the_excerpt()); ?> <!-- returns text (which you can process) -->When you’re processing it—changing the length, appending something—use get_the_excerpt().
On posts where the excerpt field is empty, text automatically cut from the start of the post content is used (with HTML tags and shortcodes stripped). In other words, the mechanism is built so that archives still work for articles with no excerpt written.
Changing the length site-wide
// Excerpt length (see the note below on how this is counted)
function my_excerpt_length($length) {
return 80;
}
add_filter('excerpt_length', 'my_excerpt_length', 999);
// Change the trailing "[…]"
function my_excerpt_more($more) {
return '…';
}
add_filter('excerpt_more', 'my_excerpt_more');Changing just one place in a template
When you want different lengths in different lists, writing it in the template is clearer than filtering.
<p class="excerpt"><?php echo esc_html(wp_trim_words(get_the_excerpt(), 60, '…')); ?></p>wp_trim_words() is the trimming function WordPress provides, and it follows the same per-language counting. It strips tags automatically too, so it’s safe whether you hand it an excerpt or the post content.
To build one from the post content, pass get_the_content().
<?php echo esc_html(wp_trim_words(get_the_content(), 60, '…')); ?>Adding your own “read more” link
The pattern where you append a link to the article after the excerpt.
<p class="excerpt">
<?php echo esc_html(wp_trim_words(get_the_excerpt(), 60, '…')); ?>
<a href="<?php the_permalink(); ?>">Read more</a>
</p>You can also return a link from the excerpt_more filter, but writing it in the template makes “where is this coming from?” much easier to trace, so I’d start with this form.
Making excerpts something people write by hand
Auto-generated excerpts often end up being “just the introductory preamble,” depending on how the article opens. Writing the text you want people to read in the archive right in the editing screen is the most reliable approach.
- Enter it in the “Excerpt” field in the right-hand panel of the post editor (if it’s not there, reveal it via ”⋮” → “Preferences” → Panels)
- For custom post types, include
'excerpt'inregister_post_type’ssupports
'supports' => ['title', 'editor', 'thumbnail', 'excerpt'],Excerpts are often used as the source of the meta description too, so they affect how you look in search results.
How long should it be?
The deciding factor is whether the cards end up the same height. Working backwards from your archive layout removes the guesswork.
| Archive shape | Rough length |
|---|---|
| Three cards across | 120–160 characters |
| Two cards across | 160–200 characters |
| A single wide list | 200–240 characters |
| A recent-posts list in the sidebar | 80–120 characters |
Uneven lengths make card heights ragged, so cutting short and long posts to the same length does a lot for the look. Once you’ve settled on a length, capping the number of lines in CSS insures you against overflow.
Checklist when nothing changes
Here are the places people get stuck on “I set it and nothing changed,” in the order to check them.
- Did you raise the priority?—
999as the third argument toadd_filter. If your theme or a plugin uses the same filter, you lose - Is there text typed in the excerpt field?—with text in the editor’s excerpt field,
excerpt_lengthhas no effect (the filter only runs for auto-generated excerpts) - Are you calling
the_excerpt()?—if the template outputsthe_content(), excerpt settings are irrelevant - Is a cache holding the old output?—clear any caching plugin or server-side cache before checking
- Did you write it in the child theme’s
functions.php?—written in the parent, it disappears on update
When you want to keep tags or line breaks
wp_trim_words() strips tags, so line breaks and emphasis in the body go too. In an archive that’s usually correct, but sometimes “keep the bold at least” is a requirement. In that case, narrow down what gets stripped.
<?php
// Keep only the tags you allow, then trim
$text = wp_kses(get_the_excerpt(), ['strong' => [], 'em' => []]);
echo wp_kses_post(wp_html_excerpt($text, 200, '…'));
?>wp_html_excerpt() trims by length without breaking tags. That said, the more complex the requirement, the more accidents, so starting out tag-free is the recommendation.
Excerpts affect how you look in search results
Many SEO plugins use the excerpt as the source of the meta description. In other words, what you write in the excerpt field can become the description text in search results.
- Put the point first—lead with the conclusion, not “in this article we will…”
- Don’t go long—search results show only so much before cutting off
- Don’t leave it as a copy of your opening paragraph—left auto-generated, it’s often nothing but preamble
Summary
- To process it, use
get_the_excerpt()(the_excerpt()outputs with a p tag) - Site-wide, use the
excerpt_length/excerpt_morefilters. When they don’t take, try priority 999 - To vary per list, use
wp_trim_words(). It strips tags before cutting, so nothing breaks - For text you really want read in an archive, writing it by hand in the excerpt field is the reliable route
- When it has no effect, check priority 999, a hand-typed excerpt, and caches—in that order
- The excerpt often becomes the meta description—lead with the point
A well-tuned archive description changes both readability and click-through.