Skip to content

Post Title block: Support custom placeholder via post type supports#75937

Closed
xristos3490 wants to merge 3 commits into
WordPress:trunkfrom
xristos3490:add/title-placeholder-post-type-support
Closed

Post Title block: Support custom placeholder via post type supports#75937
xristos3490 wants to merge 3 commits into
WordPress:trunkfrom
xristos3490:add/title-placeholder-post-type-support

Conversation

@xristos3490

@xristos3490 xristos3490 commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

What?

Adds support for a custom title placeholder in the Post Title block, driven by the post type's supports data. This lets post types define their own placeholder text (e.g., "Add product name" instead of the generic "Title").

Closes #75938

How?

  • Reads the title support data from the post type via getPostType() — when it's an array, the first element can include a placeholder property
  • Uses that placeholder throughout the block: in the static preview, the editable input, and the linked title variants
  • Splits the non-editable rendering into separate branches to avoid passing placeholder text through dangerouslySetInnerHTML
  • The "(no title)" fallback remains untouched.
  • Fully backwards compatible.

Testing Instructions

  1. Register a custom post type with title support that includes a placeholder (e.g., 'supports' => array( 'title' => array( 'placeholder' => 'Product name' ), 'editor' ))
  2. Add a Post Title block in a template or Query Loop targeting that post type
  3. Notice the placeholder displays your custom text instead of "Title""
  4. Verify standard post types (post, page) still show the default "Title" text

Screenshots

Example via tweaking WooCommerce product CPT:
post-title-placeholder-example

@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

1 similar comment
@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Feb 26, 2026
@github-actions

Copy link
Copy Markdown

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: xristos3490 <xristos3490@git.wordpress.org>

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

@xristos3490

Copy link
Copy Markdown
Contributor Author

Closing in favor of #76016

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

Labels

[Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post Title block: Allow post types to customize title placeholder text

1 participant