get the parent id of a page
Hi, I am trying to write a navigation scheme for a page that displays a list of not the parent, and nor the children of the current page, but just it’s brothers and sisters. So, if my structure is
1 – Cars
2 – Planes
and I was on the Honda page, I would want my list to display just Ford, Honda, and Chevy. I think the best way to do this is something like:
[code]wp_list_pages(‘child_of=’ . $pageParent);[/code]
but I have googled and searched the codex and am unable to figure out how to get from WordPress the ID number of the parent of the page.
The closest I found was this:
$object = $wp_query->get_queried_object();
$parent_id = $object->post_parent;
But it does not work, always returning a $parent_id of 0, even though that code is in the loop. I think I am misunderstanding the way WPQuery works.
Any help would be appreciated. Thanks!
- The topic ‘get the parent id of a page’ is closed to new replies.