Skip to content
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

PostTitle: Add fallback for empty title #69040

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

SainathPoojary
Copy link
Contributor

@SainathPoojary SainathPoojary commented Feb 5, 2025

Closes: #69039

What?

This PR fixes the Query Loop Block's Post Title component to display "(no title)" for posts without titles, maintaining consistency with WordPress core behavior in both editor and frontend.

Why?

Currently, the Post Title Block renders an empty <h2> tag for posts without titles, creating inconsistency with other WordPress interfaces like Latest Posts block and post listing pages which show "(no title)". This affects both usability and accessibility.

How?

  • Modified post-title/edit.js to display "(no title)" when fullTitle.rendered is empty
  • Updated post-title/index.php to show "(no title)" instead of returning an empty string when no title exists
  • Applied these changes for both linked and unlinked title variants

Testing Instructions

  • Create a post without a title
  • Add a Query Loop Block to new post
  • Select Post Title in the pattern or add it separately
  • Verify "(no title)" appears instead of an empty heading
  • Enable "Make title a link" in block settings
  • Verify "(no title)" appears as a linked text
  • Check both editor and frontend views

Screencast

2025-02-05.12-50-59.mp4

Copy link
Member

Choose a reason for hiding this comment

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

This would be a regression. Front-end rendered shouldn't use fallback values.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Block] Post Title Affects the Post Title Block labels Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Title Affects the Post Title Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PostTitle: Empty heading tag rendered for posts without titles
2 participants