You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Block] Query Loop Excerpt does not preserve paragraph breaks for automatic excerpts #80380
But this seems like a separate issue.
The problem is not only that inline HTML is stripped, but that the Post Excerpt block collapses multiple Gutenberg paragraph blocks into a single blob on the front end.
Excerpt block places everything into one blob.
In my case, the source post contains distinct paragraphs, but the Query Loop / Post Excerpt output does not preserve paragraph breaks.
Could this be tracked as a separate bug or enhancement for paragraph preservation in automatic excerpts?
The post uses multiple paragraphs. See the following screenshot:
It would be helpful to have the same paragraph breaks in the excerpt block as can be seen in the posts.
As it would keep a consistency between the initial look of a post and the excerpt uses elsewhere to give a preview that should look the same as the original post.
Step-by-step reproduction instructions
Create a post with multiple paragraphs.
Add the Query Loop turned into pattern into a page.
Be sure to include the excerpt and a high word count.
Notice it is in one blob and not in paragraphs as the post.
Screenshots, screen recording, code snippet
..
Environment info
Using Twenty Twenty Four and the newest Gutenberg plugin 23.5.3.
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Please confirm which theme type you used for testing.
Well I just want consistency in how a post is seen and how it is also visually seen in the preview.
It is important to keep things consistent and this one is lacking. Adding a more block just complicates it.
When for instance adding a word count of 60....if we count the 60 first words in a post it might look something like this post that contains paragraph formatting. The excerpt strips the formatting and does not show it like this.
Another example.
Here is a red outlined part of the beginning of a post.
Lets say that I add 60 words and that it would actually cover the above outlined area which would be seen in the excerpt.
Currently the excerpt would just show it like so:
Query Loop and Latest Post Excerpt blocks turns multi-paragraph content into one flat blob. Here is the code snippet I used to fix it. I made an issue in the Gutenberg repository on Github here: #80380 The problem is that post previews of the text shows up in one blob. So using the Query Loop block or the Latest Post block makes it look like this:
This is just one blob of text and a link. (not sure if the link would be added.)
Consistency:
The excerpt with its 60 words should show identical to the first 60 words of the post.
Not as one blob of text with no formatting but the same visual at the post. Meaning if there are paragraph blocks in the post then these paragraph breaks should also be seen in the excerpt.
Consistency:
The excerpt with its 60 words should show identical to the first 60 words of the post.
Not as one blob of text with no formatting but the same visual at the post. Meaning if there are paragraph blocks in the post then these paragraph breaks should also be seen in the excerpt.
What happens if a post contains blocks other than paragraph blocks at the beginning?
I would say that the excerpt should copy the first part of a post. But perhaps it should be defined differently then the first 60 words?
Perhaps the excerpt should instead of defining words say copy an amount of blocks to be seen in the excerpt.
Today we define through words. What if one wants to show a cover block with a video in it as part of the excerpt? What if one wants a direct preview of the post with the first 5 blocks as part of the excerpt? One should then define: How many blocks to show in the excerpt as a more consistent way of showing the beginning of a post. It would be more true to how the post is seen.
Now extending this...
Each post has the possibility to add a text excerpt. This excerpt could also be more advanced defined to where the user adds blocks into the excerpt box of this single post. Yes some might just want an unique text excerpt seen while others might want to add an image etc as an unique excerpt.
So to keep with consistency. Showing excerpt can be a kind of preview of the beginning of the post with blocks. OR one could make an unique excerpt through the post and add blocks to it. This way the excerpt is not only focused on text but on a more visual experience.
I got some help with a better framing of what I am working on explaining....
I think this points to a broader need for a more block-aware excerpt model.
Right now, automatic excerpts are based on word count, which can flatten the visual structure of Gutenberg content and turn multiple paragraph blocks into one blob.
If the post starts with paragraph blocks, the excerpt should preserve those paragraph breaks.
Even better, excerpts could offer a block-based mode, where the preview shows the first N blocks instead of only the first N words.
That would make previews feel more like the post itself, rather than a plain text summary.
A manual excerpt could also support blocks, so users who want a richer preview can intentionally add text, images, or other blocks.
Even better, excerpts could offer a block-based mode, where the preview shows the first N blocks instead of only the first N words.
I think this is just making things more difficult. We should simply consider how many blocks to display in the Content block.
This is an example of a filter that displays only the first three blocks of a post if the Content block has a specific CSS class. Although I haven't tested it, if we are to move forward with this issue, it means we should discuss whether to add an option to the Content block that performs the equivalent of the following filter.
I see the point about using the Content block plus a More block for a manual, controlled preview.
My concern is that the current Excerpt block behavior still flattens the automatic preview, so the issue here is not just “how to manually build a preview,” but that the default preview output does not preserve the structure of the post when it is generated automatically.
Because of that, I still think this belongs in the Query Loop / Post Excerpt behavior, since the goal is to keep the excerpt visually consistent with the opening part of the post without requiring each post to be manually configured.
If the preferred solution is a Content block option that can show only the first N blocks, that would also address the consistency problem — but it would still need to be an automatic, block-aware preview, not just a manual workaround.
That is where our opinions differ, the goal of the excerpt in WordPress has historically not been to keep visually consistent with the post and this is documented in the code reference I linked.
I agree that the current behaviour is intended rather than a bug. With that in mind, I had worked on a PR to add an opt-in toggle to "preserve formatting," which keeps the default behaviour exactly as it is but selectively allows paragraph blocks and breaks to be preserved if the user chooses. #80419
However, after going through the discussion I believe that using the Content block with the More block is the preferred approach, still for now I've left the PR open in case an opt-in solution is desired.
Having a toggle in the Excerpt block seems like a good solution. Since the Excerpt block is already part of the Query Loop, it would be much easier for users to preserve formatting with a simple option. For a beginner, that would be straightforward. The alternative of using a More block means editing each individual post, which adds extra steps and complexity. I was hoping for one simple method that works automatically.
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.
Activity
paaljoachim commentedon Jul 16, 2026
With help from Perplexity AI. I got the excerpt to show the correct preview making it similar to the real posts by using this code.
paaljoachim commentedon Jul 16, 2026
I actually made a tutorial here:
https://easywebdesigntutorials.com/how-to-keep-paragraph-breaks-in-wordpress-query-loop-previews/
It would be great to get this fixed directly in WordPress though so that I would not need to use a code snippet.
carolinan commentedon Jul 17, 2026
Hi
This is not a bug but the intended behavior of the excerpt, as documented in the code reference:
https://developer.wordpress.org/reference/functions/the_excerpt/
Note that the excerpt is a block of its own, it is not part of the query loop.
To display a small amount of content without tags stripped, use the post content block and add the more block to the content.
paaljoachim commentedon Jul 17, 2026
Hei @carolinan
Well I just want consistency in how a post is seen and how it is also visually seen in the preview.
It is important to keep things consistent and this one is lacking. Adding a more block just complicates it.
carolinan commentedon Jul 18, 2026
I don't think I understand what you mean, what preview?
t-hamano commentedon Jul 18, 2026
@paaljoachim So, you want to automatically display only the first few blocks of post content within a query loop block?
paaljoachim commentedon Jul 18, 2026
When for instance adding a word count of 60....if we count the 60 first words in a post it might look something like this post that contains paragraph formatting. The excerpt strips the formatting and does not show it like this.
Another example.
Here is a red outlined part of the beginning of a post.
Lets say that I add 60 words and that it would actually cover the above outlined area which would be seen in the excerpt.
Currently the excerpt would just show it like so:
Query Loop and Latest Post Excerpt blocks turns multi-paragraph content into one flat blob. Here is the code snippet I used to fix it. I made an issue in the Gutenberg repository on Github here: #80380 The problem is that post previews of the text shows up in one blob. So using the Query Loop block or the Latest Post block makes it look like this:
This is just one blob of text and a link. (not sure if the link would be added.)
Consistency:
The excerpt with its 60 words should show identical to the first 60 words of the post.
Not as one blob of text with no formatting but the same visual at the post. Meaning if there are paragraph blocks in the post then these paragraph breaks should also be seen in the excerpt.
t-hamano commentedon Jul 18, 2026
What happens if a post contains blocks other than paragraph blocks at the beginning?
paaljoachim commentedon Jul 18, 2026
I would say that the excerpt should copy the first part of a post. But perhaps it should be defined differently then the first 60 words?
Perhaps the excerpt should instead of defining words say copy an amount of blocks to be seen in the excerpt.
Today we define through words. What if one wants to show a cover block with a video in it as part of the excerpt? What if one wants a direct preview of the post with the first 5 blocks as part of the excerpt? One should then define: How many blocks to show in the excerpt as a more consistent way of showing the beginning of a post. It would be more true to how the post is seen.
Now extending this...
Each post has the possibility to add a text excerpt. This excerpt could also be more advanced defined to where the user adds blocks into the excerpt box of this single post. Yes some might just want an unique text excerpt seen while others might want to add an image etc as an unique excerpt.
So to keep with consistency. Showing excerpt can be a kind of preview of the beginning of the post with blocks. OR one could make an unique excerpt through the post and add blocks to it. This way the excerpt is not only focused on text but on a more visual experience.
paaljoachim commentedon Jul 18, 2026
I got some help with a better framing of what I am working on explaining....
I think this points to a broader need for a more block-aware excerpt model.
Right now, automatic excerpts are based on word count, which can flatten the visual structure of Gutenberg content and turn multiple paragraph blocks into one blob.
If the post starts with paragraph blocks, the excerpt should preserve those paragraph breaks.
Even better, excerpts could offer a block-based mode, where the preview shows the first N blocks instead of only the first N words.
That would make previews feel more like the post itself, rather than a plain text summary.
A manual excerpt could also support blocks, so users who want a richer preview can intentionally add text, images, or other blocks.
t-hamano commentedon Jul 18, 2026
I think this is just making things more difficult. We should simply consider how many blocks to display in the Content block.
This is an example of a filter that displays only the first three blocks of a post if the Content block has a specific CSS class. Although I haven't tested it, if we are to move forward with this issue, it means we should discuss whether to add an option to the Content block that performs the equivalent of the following filter.
carolinan commentedon Jul 18, 2026
Again, unsing the post content block in the template and the more block after your chosen blocks solves this.
What if on 4 posts, your count of 8 blocks work, but on the 5th post you decide you need one more block. The existing method already works for this.
Adding the more block is not more complicated than entering a custom excerpt. Yes, you have to edit each post.
paaljoachim commentedon Jul 18, 2026
I see the point about using the Content block plus a More block for a manual, controlled preview.
My concern is that the current Excerpt block behavior still flattens the automatic preview, so the issue here is not just “how to manually build a preview,” but that the default preview output does not preserve the structure of the post when it is generated automatically.
Because of that, I still think this belongs in the Query Loop / Post Excerpt behavior, since the goal is to keep the excerpt visually consistent with the opening part of the post without requiring each post to be manually configured.
If the preferred solution is a Content block option that can show only the first N blocks, that would also address the consistency problem — but it would still need to be an automatic, block-aware preview, not just a manual workaround.
carolinan commentedon Jul 18, 2026
That is where our opinions differ, the goal of the excerpt in WordPress has historically not been to keep visually consistent with the post and this is documented in the code reference I linked.
This request from 16 years ago has not recieved much attention from users or contributors: https://core.trac.wordpress.org/ticket/12084
CookieDarb commentedon Jul 20, 2026
Hi everyone,
I agree that the current behaviour is intended rather than a bug. With that in mind, I had worked on a PR to add an opt-in toggle to "preserve formatting," which keeps the default behaviour exactly as it is but selectively allows paragraph blocks and breaks to be preserved if the user chooses. #80419
However, after going through the discussion I believe that using the Content block with the More block is the preferred approach, still for now I've left the PR open in case an opt-in solution is desired.
paaljoachim commentedon Jul 20, 2026
Having a toggle in the Excerpt block seems like a good solution. Since the Excerpt block is already part of the Query Loop, it would be much easier for users to preserve formatting with a simple option. For a beginner, that would be straightforward. The alternative of using a More block means editing each individual post, which adds extra steps and complexity. I was hoping for one simple method that works automatically.
github-actions commentedon Aug 5, 2026
Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.