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

Enhance Query Block Pagination with Unique Identifiers or Post Type Parameters for Improved Multi-Block Management #60938

Closed
archiveofwork opened this issue Apr 21, 2024 · 2 comments
Labels
[Block] Query Loop Affects the Query Loop Block [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended

Comments

@archiveofwork
Copy link

image

What problem does this address?

I'm currently facing a challenge with the Gutenberg Query block in WordPress where the pagination mechanism doesn't distinguish between multiple Query blocks on the same page. When I have multiple Query blocks each set to display different post types or categories, using the pagination on one block unexpectedly affects all other Query blocks on the page. This behavior occurs because the pagination URL does not include a unique identifier or the post type being queried, leading to all Query blocks reacting to the same pagination controls.

This issue becomes particularly frustrating when designing complex pages that require multiple content sections with independent navigation. Users can become confused if navigating through posts in one section changes the displayed posts in another, which disrupts the user experience and content organization.

What is your proposed solution?

I propose enhancing the Query block's pagination feature to include a unique identifier or the post type in the pagination URL parameters. For example, appending a post_type=XX parameter to the pagination links can ensure that each Query block's pagination controls only affect the block with the respective post type or identifier.

This improvement would allow each Query block to operate independently on pages with multiple content types, significantly improving content management and navigation on complex pages. It would also align with WordPress's core philosophy of being user-friendly and adaptable to various content display needs.

By implementing this feature, Gutenberg would provide better support for developers and designers who are looking to create more dynamic and user-centric sites, enhancing the overall functionality of the block editor.

@archiveofwork archiveofwork added the [Type] Enhancement A suggestion for improvement. label Apr 21, 2024
@colinduwe
Copy link
Contributor

I was able to replicate this issue when I copy/pasted the query block (with its inner post template and pagination). In that case both instances had query ID 15 and the pagination links were all tied to query ID 15. However, if I add a different pattern via the inserter, the second query has a different ID and its pagination links correctly referred to their parent query ID. So the two queries and their pagination works as expected. If I insert a second instance of the same pattern it has the same query ID again and again the bug appears.
Screenshot 2024-04-22 at 1 15 37 PM
Screenshot 2024-04-22 at 1 15 18 PM
I bet there are other cases where a query can be added and ID isn't automatically changed to be unique. I think this should be re-tagged as a bug.

@jordesign jordesign added the [Block] Query Loop Affects the Query Loop Block label Apr 29, 2024
@skorasaurus
Copy link
Member

Hi, Thanks for reporting.

You can work around this by creating a different queryids for each of the query loop blocks on the page (or your html template) in the code editor.

Meanwhile, the original issue that you describe still needs to be fixed but it's already been reported at #55747 and you can follow its progress by subscribing to the issue there.

@skorasaurus skorasaurus added [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended and removed [Type] Enhancement A suggestion for improvement. labels Jun 13, 2024
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 [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants