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

Post Formats: Query loop shows the wrong posts when inheriting the query from the post format archive template #65320

Closed
2 tasks done
carolinan opened this issue Sep 13, 2024 · 4 comments · Fixed by #66595
Closed
2 tasks done
Assignees
Labels
[Block] Query Loop Affects the Query Loop Block [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

Description

I have only tested this with a block theme.

When a query loop block with the setting Inherit query from template is placed in an archive template for a post format,
the correct posts are shown on the front, but not in the editor. In the editor, all posts are shown.

Step-by-step reproduction instructions

First, you need a block theme, and you need to enable post format support on the active theme.
If your theme does not have a functions.php file, create one.

Example:

function twentytwentyfour_setup(){
	add_theme_support( 'post-formats', array( 'standard', 'aside', 'gallery', 'audio', 'video', 'link', 'image', 'chat', 'status', 'quote' ) );
}

add_action( 'after_setup_theme', 'twentytwentyfour_setup' );

Set the permalinks on the test installation to Post name.

Create a few posts and assign them the link post format.

Next, add a link post format archive template inside the theme's templates folder.
templates/taxonomy-post_format-post-format-link.html

Go to Appearance > Editor > Templates, locate and edit the template.
Add a query loop block. In the block settings sidebar, make sure that Inherit query from template is enabled.
Check if the query loop shows the correct posts, it should only show the posts that you assigned the link format to.
Save.

View the archive on the front: Add type/link/ after your test domain in the browser address bar.
(For example http://66.local/type/link/ )

Screenshots, screen recording, code snippet

No response

Environment info

WordPress 6.6.2, with and without Gutenberg trunk.

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
@carolinan carolinan added [Type] Bug An existing feature does not function as intended [Block] Query Loop Affects the Query Loop Block labels Sep 13, 2024
@carolinan carolinan self-assigned this Oct 30, 2024
@carolinan
Copy link
Contributor Author

While troubleshooting this I found that this is true also for tags.
If I go to Appearance > Editor > Templates > Add new and select Tag Archive .. for single item, then the editor shows a list of the most recent posts, not posts with the selected tag.

@carolinan
Copy link
Contributor Author

carolinan commented Oct 30, 2024

@ntsekouras I don't suppose you remember why the query loop was only fixed for specific category archive pages, and not other taxonomies? #44294

@ntsekouras
Copy link
Contributor

@ntsekouras I don't suppose you remember why the query loop was only fixed for specific category archive pages, and not other taxonomies? #44294

The linked PR was just a bug fix, but I guess the question now becomes why we had only the categories handling
. Maybe it seemed like the most common scenario and it was a first step?

I'm not sure though how much complexity we should add there given that in many cases the actual result could be way different with filters etc...

@carolinan
Copy link
Contributor Author

carolinan commented Nov 1, 2024

The query loop filters are working: it is the default (inherit) that is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants