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

Blog page title block displays first post title in query #38574

Closed
Humanify-nl opened this issue Feb 7, 2022 · 4 comments
Closed

Blog page title block displays first post title in query #38574

Humanify-nl opened this issue Feb 7, 2022 · 4 comments

Comments

@Humanify-nl
Copy link

Description

When rendering the page, the title of the first post in the query loop is displayed as page title. Instead of the title of the page.

After that, I've tried to add Archive Title block instead, but this doesn't render anything at all.

Is this intended behavior? How do we add a title for the blog page? All I can think of right now is a static heading in the template.

Step-by-step reproduction instructions

  1. Add a new page with page-title 'blog'.
  2. Set this page as the blog page through reading settings.
  3. Add the template home.html + header.html template part.
  4. In this template, add a Page Title block.
  5. Display the posts page and the title renders the first title in the posts loop

Screenshots, screen recording, code snippet

No response

Environment info

  • WP 5.9
  • Without Gutenberg plugin

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

@annezazu
Copy link
Contributor

Hey there! Great question. To do this, you'll want to add the Post Title Block outside of the Query Loop. From there, that will display the page title. Here's a quick video showing a poorly designed template showing what I mean:

page.title.mov

If this isn't what you meant, let me know. For now, going to close this out :)

@Humanify-nl
Copy link
Author

Humanify-nl commented Mar 2, 2022

Sorry @annezazu , I think I didn't expain my use-case correctly here.

As I am aware, setting any page as the 'blog page' in WP options, makes this into a post archive that loads in the template hierarchy from home.php / home.html. That is the exact use case.

The problem occurs outside of the query loop. It occurs on the home.html template where the 'post-title' block is assigned in a template-part; the header.

Problem: The title displays the title of first post in the loop. Not the page title (which is blog in my case). The featured image block also displays the first posts' featured image.

I don't know how the query post_id's are seeping into the header template-part to grab the title. It shouldn't. If it's in the header (or anywhere else) it should display the title of the current page, not a post in the query loop.

edit:
After inspecting TT2 and seeing no post-titles in the header template-parts, and testing my approach of putting a post-title in the header there, I see the same problem there on the home.html with a post title inside header-dark-small:
image

edit2:
I have also tested not putting it in a template-part, and the same problem occurs
image

@bradhogan
Copy link

This should be re-opened. What the op was talking about is that if you have your reading settings to let's say a "front page displays" and set your posts page to a page you have called called "blog" then in your block theme's index.html (let's assume there isn't a home.html because there doesn't have to be), then you add <!-- wp:post-title /--> outside of the query block, the output is the first post title in the query (even if it is outside of the query block) when in fact it should display the page name ("blog" in this case). Without this, there is currently no way of showing the page title for a site owner's blog page which is pretty crazy.

@Humanify-nl
Copy link
Author

Humanify-nl commented Aug 10, 2023

Thank you @bradhogan for verifying my struggle with this.

No one is using archives because menu marking is missing, everyone throws queries in a page? Not sure why this was closed. It’s the default blog experience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants