What are WordPress excerpts?
WordPress excerpts are a short summary of a post or page.
Excerpts are commonly shown on Blog pages.
You might also see them on search results pages or archive pages.
There may be a link following the excerpt to read the full post.
Here’s an example from the previous theme of my blog page:
And here’s an example from the blog theme now:
There are two types of excerpt:
- Manual excerpts
- Automatic excerpts
Manual excerpts
Manual excerpts are set by the post or page author in the Excerpt box.
If you’re a Block Editor user, a link to add an Excerpt box is in the right sidebar under the Post tab.
If you are using the Classic Editor, the Excerpt box is under the post editor.
If you don’t see the Excerpt box, it can be turned on by checking the relevant box in Screen Options.
More tag
Another way of controlling the summary shown is to use the More block or tag in WordPress.
Block editor users can find the More block in the Design section, or by searching for More.
This is what a post looks like using the More block in the editor:
For a Classic Editor user, when writing a post, use the Insert Read More Tag button in the post editor.
On the blog page it looks like this:
This method doesn’t work for pages.
Automatic excerpts
Automatic excerpts are auto-generated by WordPress using the_excerpt()
function if no manual excerpt is set. The default length of an automatic excerpt is 55 words.
All shortcodes and HTML tags are removed from automatic excerpts.
How do themes handle excerpts?
Annoyingly, each theme is different – and there’s no easy way to search for how a theme handles excerpts.
Many themes will show excerpts (manual or auto-generated) on the Blog page e.g. Checathlon.
The GeneratePress theme will show both automatic and manual excerpts on its Blog page, as shown below.
Some themes will ignore any manual excerpts and display the full post anyway on the Blog page. e.g. Twenty Seventeen.
Twenty Sixteen displays excerpts in an unexpected way. It shows the excerpt first in a larger typeface, followed by the full post.
Other themes will give the user a choice of what to display. This is often set in the WordPress Customizer in classic themes.
My theme, Genesis, does this:
Customizing excerpt length
In block themes
If you’re using a newer block theme, you can change the excerpt length by editing the blog page template. Here’s an example using the Twenty Twenty-Three theme.
Go to Appearance > Editor > Templates and select the Blog Home template from the list.
You’ll be taken to the template editor. You’ll notice that this theme ignores manual excerpts. Instead all excerpts are a maximum length of 55 words.
You can change the number of words in the excerpt by clicking on the Excerpt block and dragging the Max Number of Words slider in the Block Settings to a different value, from 10 to 100. Changing the value here applies to all excerpts.
This is what two posts look like in the editor with 70 word excerpts:
In classic themes
If you’re using a classic WordPress theme, your theme may have a settings page or WordPress Customizer setting that lets you change the excerpt length. Check your theme documentation.
If not, you can use a plugin – Advanced Excerpt.
Advanced Excerpt lets you set the excerpt length and customize the Read more link. Here is what an excerpt looks like in GeneratePress with the following options set:
Excerpt length: 30 words.
Ellipsis: … This generates three dots after the excerpt.
Read more link: Add read more link to excerpt with text “Read the rest”.
Including links and other HTML elements in WordPress excerpts
Automatic excerpts in classic themes
WordPress strips out all HTML from automatic excerpts or text prior to the More tag. So links are not shown in excerpts.
To get around this issue you can again use the Advanced Excerpt plugin.
With the default settings of Advanced Excerpt, here’s how one of my posts looks in Checathlon theme.
Three things are there that weren’t in the auto-generated excerpt – the image, the subheading and the link.
Advanced Excerpt options
There are a few adjustments you can make to the output.
Excerpt length: Default is 40 but you can increase or decrease it or choose characters instead of words.
Ellipsis: Leave blank if you don’t want the excerpt to end with … Or add another HTML entity.
Finish: Choosing Sentence makes the excerpt end at the end of a sentence rather than cutting off in the middle.
Read More Link: Checking the Add read more link to excerpt adds a link at the end of the post, which is customizable. You can:
- change the text – the default is “Read the rest”
- have the link open in a new tab (not recommended for accessibility)
- append the post title to the link for screen reader users
- have the link shown for custom excerpts too
No Custom Excerpts: If you have the Generate excerpts even if a post has a custom excerpt attached option checked, the plugin will ignore manual excerpts and create its own based on your settings. If only the option below is checked, Use the custom excerpt (if disabled the excerpt is generated from the content) you should see manual excerpts where they have been defined. The Read more link will not show unless you have the Add the link even if a custom excerpt is shown from the Read More Link options checked.
Link Whole Excerpt: Turns the entire excerpt into a link to the post.
Strip Shortcodes: removes shortcodes from the excerpt.
Filter: filters the_excerpt()
and the_content()
functions in your site.
Disable On: Disables Advanced Excerpt in certain places e.g. your home page.
Strip Tags: Removes all tags except any you choose to keep. To keep links, check the box for the a
tag.
Here is another example with the following options:
- Ellipsis: »
- Finish: Sentence
- Strip Tags: Remove all tags except the following: a
Manual excerpts with links in classic themes
You can set manual excerpts with links or other HTML tags by adding the tags to your excerpt. The easiest way to do this if your excerpt is based on the post content is to copy the relevant content from the editor and paste it into the excerpt box.
If you’re a classic editor user, you can switch to the code view and copy and paste the relevant text, and then paste it into the Excerpt metabox.
Block editor users need to switch to the code editor:
And then copy the relevant code:
Then add the code to the Excerpt box and save it.
Here’s how the excerpt looks in GeneratePress, without the Advanced Excerpt plugin active:
If you have a lot of manual excerpts, here’s some code you could try if you want manual excerpts with links. It needs to be added to your theme functions.
Further reading: How To Add Functions To Your WordPress Site Safely
Excerpts with links or HTML tags in block themes
Unfortunately, at the time of writing, block themes use the Excerpt block for displaying excerpts, and this block strips HTML tags from the excerpt so you can’t have links or other HTML e.g. bold text in a block theme excerpt – even if you have set an excerpt manually with tags.
This is a known issue and is documented here: [Block] Post Excerpt – Allow inline HTML tags. There are a couple of code solutions suggested, but I tried them and couldn’t get them to work. For the time being it looks as if we’ll have to wait for an answer.
What about using the Advanced Excerpt plugin?
Here, in this example from Twenty Twenty-Three theme; you can see that the plugin is setting the excerpt length to 40 words, but the links in the excerpts aren’t there and neither is the Read more link.
Plugin user arnkoe wrote a post on the plugin’s support forum about the excerpt Read more links not working in Twenty Twenty-Three, and fellow user butesa has created a patch. I hope that this will be incorporated into a future release of the plugin soon.
Found this post helpful? Why not share it!
Steve Teare says
Claire-
Thanks for explaining this. Very helpful.
-Steve
Claire Brotherton says
Cheers Steve – thanks for reading. 🙂
Mark McGuire says
It can be a pain with excerpts. I have tried plugins in the past with some success. It was not until I came across a great tutorial on StackExchange that allowed me to add to the functions.php without the need for a plugin. It allowed for HTML formatting in case people wanted links or bold face or lists.
I’m still experimenting what I really want but for now, I have limited to 24 words with the function to cut off at the end of the sentence (as opposed to mid-sentence).
If you are curious, here’s the link StackExchange Allow HTML in excerpts.
Gotta love Genesis.
Claire Brotherton says
Thanks Mark, that’s a useful piece of code.
I wonder if someone could turn it into a plugin?
Emily Brown says
Nice Article Claire!!
Thanks for the wonderful post. I was searching about the excerpts and you have explained it very well and clearly. I like it.
Matt says
Thank you for explaining the topic and for the Advanced Excerpt plugin mention. That was very helpful! Keeps links on the home page to get maximum value, yet reduces odds of Google penalties due to thinking full blog posts on home = a poorly-constructed PBN domain.
Thanks!
Claire Brotherton says
Thanks Matt!
Sensmedia says
Thanks Claire, you point me up to the right way! Keep it up!
John Lawson says
Very resourceful article. Thanks for sharing….