core/post-title not showing the correct title in dynamic block when used outside loop with postId context #68369
Labels
[Block] Post Title
Affects the Post Title Block
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Description
core/post-title block is a dynamic block and uses
render_block_core_post_title
method to render title.When creating dynamic blocks, we can pass
postId
andpostType
on a parent blockprovidesContext
. This would then mean that core blocks such as post-title, post-featured-image, post-excerpt etc are scoped to a particular post outside loop.Issue
is used within the method to retrieve permalink for the post, but
get_the_title()
is used without passing$block->context['postId']
as a parameter. this causes an issue where the title is rendered for the current global $post and permalink for post from context postId.Desired outcome
$block->context['postId']
should be used for the $title as well to ensure that the right title is retrieved.This would ensure that
core/post-title
is scoped to a correct post same as other post related core blocks.Step-by-step reproduction instructions
The post title in edit page will be scoped correctly, and will be scoped to global $post on the front end.
Screenshots, screen recording, code snippet
No response
Environment info
WordPress - 6.7.1
Active theme - Twenty Twenty-Five
Any browser
Viewing on Mac OS, but the problem is not device specific
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
The text was updated successfully, but these errors were encountered: