Skip to content

Excerpt Block: Add character count option #69579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

dhruvikpatel18
Copy link
Contributor

@dhruvikpatel18 dhruvikpatel18 commented Mar 14, 2025

Closes #53824

What?

This PR adds a character count option to the Excerpt Block as an alternative to the existing word count functionality, allowing theme designers to control excerpt lengths more precisely.

Why?

As noted in issue #53824, using word count for excerpts results in unpredictable lengths due to different word sizes. This makes it difficult for theme designers to create consistent grid layouts where cards need to be the same size. Character count provides a more predictable measure for controlling excerpt length, resulting in more consistent designs.

Testing Instructions

  1. Add an Excerpt Block to a post or page
  2. In the block settings sidebar, note the new "Count type" dropdown option
  3. Switch between "Words" and "Characters" count types
  4. Observe how the "Max number of words" label changes to "Max number of characters"
  5. Verify that when using character count, the excerpt is trimmed precisely to the specified number of characters
  6. Test with different excerpt lengths to ensure both modes work correctly

Screenshots or screencast

Excerpt.block.mov

@dhruvikpatel18 dhruvikpatel18 marked this pull request as ready for review March 14, 2025 17:22
Copy link

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @Ren2049.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

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

Unlinked contributors: Ren2049.

Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org>

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

@shail-mehta shail-mehta added [Type] Enhancement A suggestion for improvement. [Block] Post Excerpt Affects the Post Excerpt Block labels Mar 15, 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] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Excerpt Block]: Character count instead of word count would make this block more useful and predictable for blog designs
2 participants