-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
The Post Title block does not display the blog page name within template outside query #52668
Comments
@likethegoddess The only future-proof solution I use is to build a "Blog page title" pattern (in <?php
/**
* Title: Blog page title
* Slug: twentytwentythree/blog-page-title
* Categories: header
*/
$blog_page_id = get_option( 'page_for_posts' );
?>
<!-- wp:heading {"level":1} -->
<h1 class="wp-block-heading"><?php
if ( $blog_page_id ) {
echo get_the_title( $blog_page_id );
} else {
echo esc_html_x( 'Blog', 'Fallback blog page title.', 'twentytwentythree' );
}
?></h1>
<!-- /wp:heading -->
<?php if ( has_excerpt( $blog_page_id ) ) : ?>
<!-- wp:paragraph -->
<p><?php echo get_the_excerpt( $blog_page_id ); ?></p>
<!-- /wp:paragraph -->
<?php endif; Then I insert the pattern into |
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 Example code:
|
Description
On #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
<!-- wp:post-title /-->
beforeor
<!-- wp:post-title /-->
beforeScreenshots, screen recording, code snippet
FSE HTML template
Classic PHP template
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: