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: Fix 'parents' argument validation #68983

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

Mamaduka
Copy link
Member

What?

Part of #68620

PR updates Query parents argument validation for hierarchical post types to allow querying only top-level entries, using "parents":[0].

Why?

  • A zero is a valid parent ID for hierarchical post types. Used to display top-level items.
  • Helps developers provide custom query patterns that only display top-level pages.

Testing Instructions

  1. Ensure you have a couple of pages with and without parents.
  2. Create a page.
  3. Add a Test Query using the code editor.
  4. Confirm that the Query block displays only the top-level items.

Testing Instructions for Keyboard

Same.

Test Query

Markup

<!-- wp:query {"queryId":1,"query":{"perPage":10,"pages":0,"offset":0,"postType":"page","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false,"parents":[0],"format":[]}} -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:post-title /-->

<!-- wp:post-date /-->
<!-- /wp:post-template -->

<!-- wp:query-pagination -->
<!-- wp:query-pagination-previous /-->

<!-- wp:query-pagination-numbers /-->

<!-- wp:query-pagination-next /-->
<!-- /wp:query-pagination -->

<!-- wp:query-no-results -->
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when a query returns no results."} -->
<p></p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results --></div>
<!-- /wp:query -->

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Block] Query Loop Affects the Query Loop Block labels Jan 31, 2025
@Mamaduka Mamaduka self-assigned this Jan 31, 2025
Copy link

Flaky tests detected in ae0aa39.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13071058461
📝 Reported issues:

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
Status: 🔎 Needs Review
Development

Successfully merging this pull request may close these issues.

1 participant