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

Query block: is not respecting perPage attribute in inherited context #40996

Closed
Tracked by #41405
madhusudhand opened this issue May 11, 2022 · 5 comments
Closed
Tracked by #41405
Labels
[Block] Query Loop Affects the Query Loop Block

Comments

@madhusudhand
Copy link
Member

Description

In the query block, when inherit is set to true, query block always shows 10 posts and doesn't respect the perPage value.

Step-by-step reproduction instructions

The following query with inherit: false shows 3 posts.

<!-- wp:query {"queryId":18,"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false}} -->

Same query with inherit: true shows 10 posts.

<!-- wp:query {"queryId":18,"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true}} -->

Screenshots, screen recording, code snippet

No response

Environment info

  • Latest GB

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

@madhusudhand madhusudhand added the [Block] Query Loop Affects the Query Loop Block label May 11, 2022
@carolinan
Copy link
Contributor

When the query inherits the context, it uses the WordPress "Blog pages show at most" global reading setting, and I believe this is working as intended.

How to communicate that this is intended, when it is not expected, is something that needs to be solved 🤔

@priethor
Copy link
Contributor

priethor commented May 27, 2022

@carolinan if I'm understanding correctly, the perPage setting will be ignored whenever the inherit option is enabled as it will ultimately be overridden by the global setting, is that so? In that case, the perPage setting should be hidden when when inherit is enabled.

@carolinan
Copy link
Contributor

carolinan commented May 30, 2022

That is my understanding.
The per page setting is already hidden when inherit is enabled. It is removed from the toolbar.

I think it would be good of these two per page values always matched.
Oh never mind, they can't match because different queries need to be able to have different numbers.

@ntsekouras
Copy link
Contributor

Thanks for the issue @madhusudhand!

When the query inherits the context, it uses the WordPress "Blog pages show at most" global reading setting, and I believe this is working as intended.

That is intended and should be that way, as we have explicitly set the Query to inherit the global query. It's also true that if we toggle to inherit, we hide the per_page settings in the block toolbar. We also have logic in the block to get the value from settings if we create a new Query and the per_page option is not set and the inherit is true, but with the existing block variations(all set inherit:false), this is only possible from patterns with these settings.

Maybe the solution here could be to update the per_page to the site's setting when we set inherit:true to be more indicative in the editor. In general there are still some nuances of having a good preview in the editor of an inherited Query Loop block and a simple example would be the index template. We don't know what to show in the editor as the index is a fallback for everything 😄 .

@madhusudhand
Copy link
Member Author

Thanks @carolinan @ntsekouras for the inputs and details of the behaviour 😄. This helps resolving my issue.
Please consider it as resolved.

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
Projects
None yet
Development

No branches or pull requests

4 participants