#5742 closed enhancement (invalid)
add child_of to query_posts
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | needs-patch |
Focuses: | Cc: |
Description
IT would be a nice, simple enhancement to core if we allowed a "child_of" parameter in query_posts. This would add a lot of flexibility to themes and such, making it easier to make index pages for site sections.
(Disclaimer -- I cribbed the code straight from westi's plugin :-) )
Attachments (1)
Change History (9)
#4
@
16 years ago
- Milestone 2.9 deleted
- Resolution set to invalid
- Status changed from new to closed
Actually, "child_of" is the wrong name for this parameter, if we're going to be consistent with how it's used elsewhere in WP.
- "child_of" - Selecting the "child_of" X should return all the descendants of X (children, grandchildren, great-grandchilren, etc.).
- "parent" - Selecting the "parent" X should return just the immediate, first-generation children of X, not all descendants.
Patch shows a query for "parent," which we can get already with the "post_parent" parameter.
I'm closing as invalid because we can already do what the patch does with "post_parent."
#5
follow-up:
↓ 6
@
16 years ago
- Keywords needs-patch added; has-patch removed
- Milestone set to 2.9
- Resolution invalid deleted
- Status changed from closed to reopened
filosofo -- Either I am misunderstanding you, or you are misunderstanding this patch.
post_parent works in different circumstances. This patch allows you to use the following in a template:
query_posts('child_of='.$post->ID);
I use it (for example) for a "section index" page -- I create a loop that lists just the children of the current page. if I can do this somehow with "post_parent", could you please give a simple example?
This won't be going to 2.8 anyway (feature freeze), so I'll update the patch for 2.9 after 2.8 is released.
If appropriate, I can change the parameter from "child_of" to "parent", though it seems a bit unintuitive to use "parent" as "this is the parent of...." (But if that's the standard in WP, so be it.)
#6
in reply to:
↑ 5
@
16 years ago
Replying to strider72:
filosofo -- Either I am misunderstanding you, or you are misunderstanding this patch.
post_parent works in different circumstances. This patch allows you to use the following in a template:
query_posts('child_of='.$post->ID);
I use it (for example) for a "section index" page -- I create a loop that lists just the children of the current page. if I can do this somehow with "post_parent", could you please give a simple example?
query_posts(array( 'post_parent' => $post->ID, 'post_status' => 'any', 'post_type' => 'any' ));
though it seems a bit unintuitive to use "parent" as "this is the parent of...." (But if that's the standard in WP, so be it.)
I agree. I wish whoever had come up with these had used more explicit names, such as "descendant_of" or "parent_of". But that's what we're stuck with.
#7
@
16 years ago
- Resolution set to invalid
- Status changed from reopened to closed
Huh. That does indeed work. I'm a bit confused though, because looking at the core code, I don't see "post_parent" in the $public_query_vars array (in includes/classes.php). I thought that array had all the parameters for query_posts() -- thus my confusion.
Thanks filosofo -- i just eliminated one plugin from my site. :)
Adds "child_of" parameter to query_posts