On a child page, I would like to query some custom fields of the parent page as well as show all the child pages of the parent page as well? (ideally in the list of child pages, i should be able to identify which child page it is currently on)
Here’s the code I am using
<?php if($post->post_parent):
$parent = get_post($post->post_parent);
?>
<h2><?=$parent->address;?></h2>
<? parent->get('address');?>
<?php endif; ?>
This should help get you started:
I’m guessing you meant to have a custom field named ‘address’ within the parent page that you could query. Otherwise, please clarify what you mean by ‘address’ (if it’s a custom meta field, a theme option, or something else).
WARNING: The $children variable will only grab the descendants of its matching parent. NOT its top-level ancestor. That means if the current page is a grandchild, or great-grandchild, the parent page will be the child of another page.
If you want to grab that top-level ancestor, I’ve written a function that does this recursively, but it’s pretty ugly. I would advise against going that route.
EDIT: Use get_page(), not get_post(). Posts are not hierarchical.