Skip to content

Post Excerpts Block: Fix "read more" theme override#71179

Merged
scruffian merged 2 commits intoWordPress:trunkfrom
BogdanUngureanu:fix/post-excerpt-read-more
Aug 14, 2025
Merged

Post Excerpts Block: Fix "read more" theme override#71179
scruffian merged 2 commits intoWordPress:trunkfrom
BogdanUngureanu:fix/post-excerpt-read-more

Conversation

@BogdanUngureanu
Copy link
Copy Markdown
Contributor

@BogdanUngureanu BogdanUngureanu commented Aug 12, 2025

What?

When a classic theme has a custom filter for except_more and the site is using query block in a page configured with a read more text, the site displays both "Read more" links.

Gutenberg should hide the read more text set by the theme to avoid having duplicate "Read more" strings.

Why?

This PR fixes this issue by removing the theme filter and using only the Gutenberg read more config.

How?

We simply need to move where we apply the filter. It needs to be before the excerpt is retrieved from the DB.

Testing Instructions

  1. Install a theme with a read more link
  2. Create a long post (you can use the lorem ipsum generator)
  3. Create a page and add the query block
  4. Make sure you have the excerpt configured with the "More text"
  5. Go to the page's front-end
  6. Notice that you have two "Read more" elements: one from the theme and one from the Post Excerpt block
  7. Install the changes from this PR and notice that we only have the "Read more" configured in the block

Testing Instructions for Keyboard

Screenshots or screencast

Before After
Screenshot 2025-08-12 at 18 53 04 Screenshot 2025-08-12 at 18 54 00

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 12, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: BogdanUngureanu <bogdanungureanu@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] Post Excerpt Affects the Post Excerpt Block labels Aug 13, 2025
)
);

$post_id = wp_insert_post(
Copy link
Copy Markdown
Contributor Author

@BogdanUngureanu BogdanUngureanu Aug 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't use the factory for the post because the post excerpt needs to be generated automatically. The factory method on the post has a default stubbed value for the excerpt.

Copy link
Copy Markdown
Contributor

@scruffian scruffian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this and it works as advertised. The code change looks good too. 🚢

@scruffian scruffian merged commit 9eafb17 into WordPress:trunk Aug 14, 2025
76 of 78 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.5 milestone Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Post Excerpt Affects the Post Excerpt Block [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants