I am using wp_list_pages to show the page structure on a website. For instance, if I use this code, it will show me the complete child / grandparent heirarchy of the current page the user is on:
wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
So this would generate something like this: (keep in mind, the user is on a page called About, which is the parent)
This works great, but if you were to click on any grandparent page (Like Partners), the wp_list_pages
code does not work. I have implemented a conditional statement which will use different code on a child page then the grandparent page. So that said, I have the child pages working great. I just need to figure out how to display this same exact menu on the grandparent pages.
Any idea?
Here is how the conditional work:
<?php if( count(get_post_ancestors($post->ID)) == 2 && $post->post_parent){ ?>
I need new code here
<?php } elseif(count(get_post_ancestors($post->ID)) == 1 && $post->post_parent){
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
echo $children;
}
else { ?>
<li>Parent Page</li>
<?php } ?>