On https://github.com/WordPress/gutenberg/issues/22724, the Post Title block is designated as the equivalent to the single_post_title() tag. In classic theme dev, one use of the single_post_title() tag is to display the name of the blog page title before the loop on the index.php template.
I would expect that adding the Post Title block before the Query block on the index.html template would display the blog page title before the query results. Instead, nothing is displayed.
When I created a home.html template and added a Post Title Block before the Query block, the title of the first query result is displayed instead of the title of the page.
Step-by-step reproduction instructions
1) Go to template > index.html within a block theme.
2) Add <!-- wp:post-title /--> before
or
1) Go to template > index.html within a block theme.
2) Duplicate file and rename home.html.
3) Add <!-- wp:post-title /--> before
@likethegoddess
I came across the same issue. The only solution I could find was to set up the Post Title context postId to the actual blog page ID using PHP. However, this only worked for brief amount of time as it seem it is going to be removed (still works with current Gutenberg 16.2.1).
The only future-proof solution I use is to build a "Blog page title" pattern (in twentytwentythree/patterns/blog-page-title.php, for example) containing a code such as:
Thanks, @webmandesign, that's exactly what I needed. That's a shame the context is being removed. There has to be some way to accomplish this going forward.
I am trying to return parsed post_content outside the loop via the rest api for a dynamic modal, and requiring the $post object to be global appears to be a breaking issue. The render_block_context filter is used to inject the post_id, which works for the core/post-featured-image block, but not the core/post-title block.
Description
On https://github.com/WordPress/gutenberg/issues/22724, the Post Title block is designated as the equivalent to the
single_post_title()
tag. In classic theme dev, one use of thesingle_post_title()
tag is to display the name of the blog page title before the loop on the index.php template.I would expect that adding the Post Title block before the Query block on the index.html template would display the blog page title before the query results. Instead, nothing is displayed.
When I created a home.html template and added a Post Title Block before the Query block, the title of the first query result is displayed instead of the title of the page.
Step-by-step reproduction instructions
1) Go to template > index.html within a block theme. 2) Add
<!-- wp:post-title /-->
beforeor
1) Go to template > index.html within a block theme. 2) Duplicate file and rename home.html. 3) Add
<!-- wp:post-title /-->
beforeScreenshots, screen recording, code snippet
FSE HTML template
@likethegoddess I came across the same issue. The only solution I could find was to set up the Post Title context
postId
to the actual blog page ID using PHP. However, this only worked for brief amount of time as it seem it is going to be removed (still works with current Gutenberg 16.2.1).The only future-proof solution I use is to build a "Blog page title" pattern (in
twentytwentythree/patterns/blog-page-title.php
, for example) containing a code such as:Then I insert the pattern into
index.html
template file using<!-- wp:pattern {"slug":"twentytwentythree/blog-page-title"} /-->
.Thanks, @webmandesign, that's exactly what I needed. That's a shame the context is being removed. There has to be some way to accomplish this going forward.
I am trying to return parsed
post_content
outside the loop via the rest api for a dynamic modal, and requiring the $post object to be global appears to be a breaking issue. Therender_block_context
filter is used to inject thepost_id
, which works for thecore/post-featured-image
block, but not thecore/post-title
block.Example code: