Skip to content

Latest posts: Render blocks in full content#76000

Draft
carolinan wants to merge 2 commits intotrunkfrom
update/latest-posts-content-filter
Draft

Latest posts: Render blocks in full content#76000
carolinan wants to merge 2 commits intotrunkfrom
update/latest-posts-content-filter

Conversation

@carolinan
Copy link
Copy Markdown
Contributor

@carolinan carolinan commented Feb 27, 2026

What?

Closes #69427, #70546
This PR intends to resolve the issue with the block markup being printed on the front, and the missing styles, when the latest posts block is set to display the full post content.

How?

When the option to display the full post content is enabled, use the_content filter to render nested blocks and styles.

Also add a check for the post id, to prevent infinite loops if the post content contains the latest posts block, and prints a "rendering halted" message on the front if debug is enabled.

Using do_blocks() here would also work. I have no strong preference for either, I used the_content because it has been requested by extenders in #70546.

This is basically a copy of what is already used in the post content block, template parts, and patterns
https://github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/post-content/index.php#L27

Testing Instructions

  1. Create a new post and add a Cover block with image and text
  2. Create a new post and inset the latest posts block, configured to show full content
  3. Create a new page and inset the latest posts block, configured to show full content
  4. View the page on the front, confirm that the cover block shows correctly and that there is no block comment printed in the source.
  5. If you have WP_DEBUG and WP_DEBUG_DISPLAY enabled, you should see a message saying
    [block rendering halted]

AI assistance: Yes
Tool(s): GitHub Copilot
I told Copilot where to look, it wrote the code and then we discussed the pros and cons of do_blocks() vs the_content().

When the option to display the full post content is enabled, use the_content filter to render nested blocks and styles.

Add a check for the post id, to prevent infinite loops if the post content contains the latest posts block. Display the "rendering halted" message if debug is enabled.
@carolinan carolinan added the [Type] Bug An existing feature does not function as intended label Feb 27, 2026
@github-actions github-actions bot added [Package] Block library /packages/block-library and removed [Type] Bug An existing feature does not function as intended labels Feb 27, 2026
@carolinan carolinan added [Block] Latest Posts Affects the Latest Posts Block [Type] Bug An existing feature does not function as intended labels Feb 27, 2026
@carolinan
Copy link
Copy Markdown
Contributor Author

carolinan commented Feb 27, 2026

@getdave Hi, 😊 I didn't see your latest posts blocks PR #74866 in time, should I close this? They don't solve the exact same issue but it's the same cause.

@github-actions
Copy link
Copy Markdown

Flaky tests detected in 7aaece1.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23186299287
📝 Reported issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Latest Posts Affects the Latest Posts Block [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The latest posts block prints the block comment on the front when the full post is enabled

1 participant