-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 Loop Block: Set depth limit #68620
Comments
It is not ideal, but you can do this by setting the
This might require REST API changes first. I don't remember if similar queries are supported. |
Interesting idea to do it via the code view. Sadly I seam not to work fully. Inside the site editor it looks good. But in the frontend it doesn't work. The query in frontend seam to have some extra validation. Here in a video: Outside the video I tried to filter by "Sample page". That works. |
I think it is due to this line in the |
@Drivingralle, create PR that should resolve The next step would be to provide a UI and allow users settings this value. Requesting feedback because I'm unsure what's the best solution here. One option could be to have a static token, something like "No parent", which maps to Screenshot |
@Drivingralle, the #68983 is merged now. You should be able to create similar queries programmatically. |
@kjnanda, #68983 only partially solves the issue by allowing programmatically setting Regarding UI - The Parent filter will be updated once there's a good design proposal. |
Okay, got it! Thank you for the prompt response! 🙌🏻 |
Moving this out of the WP 6.8 project board. We could resume working on this enhancement once there's a design proposal. Meanwhile, consumers can programmatically set |
What problem does this address?
While setting up a Query-Loop block inside the footer to list posts from a CPT, the query is fetching post from all levels. I want to limit the query to just the top level.
If the posts would be children of a singular post I could use the parents field. But for top level post don't have a parent and there is no way to set the
parents
field to 0.A custom WP_query in classic world can do this.
Also changing the query of the Query block via a php filter works.
What is your proposed solution?
Similar to my suggestion in #54461 it would be possible to give the
parents
field an option to set it to no-parent/top-level/0.Alternatively and way more complicated:
Add an option to the
filter
panel to set the depth of the query to X levels deep.This setting could be combined with the parents field. Fetching post at are children of "post-id" or grand-children X levels down.
The text was updated successfully, but these errors were encountered: