Skip to content

Conversation

@ItsYash1421
Copy link

Fixes #74133

What?

Closes #74133

Adds the missing ellipsis (…) to the Post Excerpt block on the frontend when the excerpt is trimmed and a read more link is present.

Why?

The ellipsis was correctly displayed in the editor but missing on the frontend, creating an inconsistent user experience. When users add a "read more" link to a trimmed excerpt, the ellipsis should appear to indicate the content continues, matching the editor preview.

How?

  • Track whether the excerpt was actually trimmed by storing the original excerpt and comparing it with the trimmed version
  • Pass an empty string as the third parameter to wp_trim_words() to prevent it from automatically adding its own ellipsis
  • Manually add … when the excerpt is trimmed and displayed inline with the read more link

Testing Instructions

  1. Use TT4 or any block theme
  2. Create a new post with long content (more than 55 words in the excerpt or content)
  3. Go to the Site Editor and edit a template that displays posts (e.g., Home or Archive template)
  4. Add or locate the Post Excerpt block
  5. In the block settings, add "Read more" text (e.g., "Continue reading")
  6. Test with "Show link on new line" disabled (inline mode)
  7. Save the template and view the frontend
  8. Verify the ellipsis (…) now appears before the "Read more" link
  9. Also test with "Show link on new line" enabled to ensure no regression

Testing Instructions for Keyboard

  1. Navigate to the Post Excerpt block using Tab key
  2. Press Enter to select the block
  3. Use Tab to navigate to the block settings sidebar
  4. Use arrow keys to navigate to "Read more" text field
  5. Type "Read more" text
  6. Tab to "Show link on new line" toggle and test both states with Space key
  7. Save and verify on frontend using keyboard navigation

@github-actions github-actions bot added the [Package] Block library /packages/block-library label Dec 20, 2025
@github-actions
Copy link

github-actions bot commented Dec 20, 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: ItsYash1421 <[email protected]>
Co-authored-by: SirLouen <[email protected]>
Co-authored-by: iamtakashi <[email protected]>

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

@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ItsYash1421! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 20, 2025
Copy link
Member

@SirLouen SirLouen left a comment

Choose a reason for hiding this comment

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

Test Report

Description

❌ This report can't validate that the indicated patch works as expected.

Environment

  • WordPress: 7.0-alpha-61215-src
  • PHP: 8.2.29
  • Server: nginx/1.29.3
  • Database: mysqli (Server: 8.4.7 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 143.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Three 1.6
  • MU Plugins: None activated
  • Plugins:
    • Gutenberg 22.3.0
    • Test Reports 1.2.1

Testing Instructions

  1. Using TT3 theme
  2. Added the Read more
  3. 🐞 The ellipsis only appears on the editor, not in the frontend

Actual Results

  1. ❌ Issue resolved with patch.

Supplemental Artifacts

Editor:
Image

Frontend:
Image

@SirLouen SirLouen added [Type] Bug An existing feature does not function as intended [Block] Post Excerpt Affects the Post Excerpt Block labels Dec 20, 2025
@ItsYash1421 ItsYash1421 requested a review from SirLouen December 21, 2025 06:19
Copy link
Member

@SirLouen SirLouen left a comment

Choose a reason for hiding this comment

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

@ItsYash1421 you have not changed anything in the last 3 commits, only added and removed package.json, and changed the unit tests.

@ItsYash1421
Copy link
Author

@ItsYash1421 you have not changed anything in the last 3 commits, only added and removed package.json, and changed the unit tests.

The changes are working fine here is screenshots after applying changes.

In editor:
Screenshot 2025-12-21 at 8 16 23 PM

In Frontend:
Screenshot 2025-12-21 at 8 17 54 PM

@SirLouen
Copy link
Member

@ItsYash1421 we are doing something differently for sure. Can you share a screencast of the whole process?

@ItsYash1421
Copy link
Author

@ItsYash1421 we are doing something differently for sure. Can you share a screencast of the whole process?

1221.mov

@ItsYash1421
Copy link
Author

I think it was not working with Number of words more than 55

@SirLouen
Copy link
Member

I think it was not working with Number of words more than 55

I was not touching the number of words, so yes, probably. This must work for all numbers.

@ItsYash1421
Copy link
Author

I think it was not working with Number of words more than 55

I was not touching the number of words, so yes, probably. This must work for all numbers.

i fixed it in latest commit please check

* Otherwise, the read more link filter from the theme is not removed.
*/
add_filter( 'excerpt_more', $filter_excerpt_more );
$filter_excerpt_length = static function () {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this is the best fix. I have a hunch that there is probably something intrinsecal, maybe in Core. More research is required here.

Copy link
Author

Choose a reason for hiding this comment

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

The issue is that WordPress Core's get_the_excerpt() applies the excerpt_length filter (default 55 words) during frontend rendering. The editor avoids this by getting the raw excerpt via REST API (which already has the filter override).

My fix extends this same pattern to frontend rendering, ensuring consistency between editor and frontend for excerpt lengths 56-100 words. This mirrors the existing approach rather than introducing a new pattern.

Copy link
Member

Choose a reason for hiding this comment

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

I've tried over 55 and its not showing in the ellipsis frontend.
Anyway I don't like the filter solution. I will give it a thought on how to improve it

Copy link
Author

Choose a reason for hiding this comment

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

ok

@SirLouen SirLouen added the Needs Technical Feedback Needs testing from a developer perspective. label Dec 24, 2025
@SirLouen SirLouen force-pushed the fix/post-excerpt-missing-ellipsis-74133 branch 3 times, most recently from bb8668a to e957b92 Compare December 29, 2025 19:55
@SirLouen SirLouen self-requested a review December 30, 2025 00:54
@SirLouen SirLouen force-pushed the fix/post-excerpt-missing-ellipsis-74133 branch from e957b92 to 0bfbe09 Compare January 6, 2026 16:21
@SirLouen SirLouen force-pushed the fix/post-excerpt-missing-ellipsis-74133 branch from 0bfbe09 to d84df43 Compare January 6, 2026 23:15
@SirLouen SirLouen changed the title Post Excerpt: Add missing ellipsis on frontend when read more link is present Post Excerpt: Fix length limits for both Editor and Front and fix ellipsis consistency. Jan 6, 2026
@SirLouen SirLouen changed the title Post Excerpt: Fix length limits for both Editor and Front and fix ellipsis consistency. Post Excerpt Block: Fix length limits for both Editor and Front and fix ellipsis consistency. Jan 6, 2026
Copy link
Member

@SirLouen SirLouen 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 reviewed this, and now it looks legit.

Here are the changes (this is easily visible in Twenty Twenty Three theme)
Currently the excerpts display can only handle correctly the manual excerpts. But if we are using the automatic excerpts, there are inconsistencies between the editor and the front end.

The solution is to extend a little the current flow to have a unified mechanism to display for both the automatic and manual excerpt the limit of the RangeControl (100 words).

Using this url for testing (with 2023 theme):
/wp-admin/site-editor.php?p=%2Fwp_template%2Ftwentytwentythree%2F%2Findex&canvas=edit

Adding or not adding Read More as pointed out in #74133 should be irrelevant; in any case, with and without Read More and for automatic and manual excerpts, it should behave identically: if there are more words available than the maximum selected in the RangeControl the ellipsis should appear for both editor and frontend.

Editor:

Image

Frontend

Image

cc @ntsekouras I noticed you worked in the render excerpt part, could you do a final second review to double check everything is in order now?

@SirLouen SirLouen requested a review from ntsekouras January 7, 2026 00:18
if ( is_admin() ) {
add_filter( 'excerpt_length', 'block_core_post_excerpt_excerpt_length', PHP_INT_MAX );
}
add_action(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this change affects anything. Do you know why we had defined( 'REST_REQUEST' ) && REST_REQUEST ) (essentially wp_is_serving_rest_request)?

It seems this change to have the same effect, but I might be missing something.

Copy link
Member

Choose a reason for hiding this comment

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

This was proposed for #48654 and @mcsf got some concerns that were not addressed in #44964. The problem is that he is not addressing either the problem of the frontend, the ellipsis variations (difference between ... and [...] and the scenario of the automatic excerpts).

The problem is that there was no unified logic.

Now the logic is unified for all 3 cases

  • For admin, it will called inmediately during init
  • For REST API Requests (in this case in for the editor) its called via rest_api_init.
  • Frontend, on ìnit`

Before it was calling during init but REST_REQUEST was not defined yet. So for the manual excerpts it worked well, but for the automatic excerpts that were built through the API, it was not building the right excerpt. In fact by default in Core, manual excerpts should be shown completely, and what it's handled is the lenght of the automatic excerpts (not the other way around as it's being done here).

@SirLouen SirLouen requested a review from ntsekouras January 10, 2026 00:08
* wp_trim_words is used instead.
*
* To ensure the block's excerptLength setting works correctly for auto-generated
* excerpts, we temporarily override excerpt_length to 100 (the max block setting)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be to 101, no? A small rewording here to either mention 101 and that 100 is the max setting or something like override to x + 1 of the maximum setting.

Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Left a small docs comment but this seems to be fine. Something related that could be handled either here or separately, is a small inconsistency between editor and front-end for custom excerpts.

I tested a post with a big custom excerpt (more than 100 words) and in the editor we show one more word than the front-end.

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 First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository Needs Technical Feedback Needs testing from a developer perspective. [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.

Post Excerpt: Missing ellipsis on the front of the site when the read more link is added

3 participants