I'm trying to create a somewhat complicated CMS-like navigation system for my static pages. Here's a basic overview of the page structure:
Home
About
Products
-Things
-Items
--Different types of items
--Origin of the names of items
--Etc.
-Widgets
-Dongles
Contact
So, there are parent pages, child pages, and grandchild pages.
In the sidebar I was successfully able to display only the parent page and only the children. That was easy:
<?php
if($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1");
$parent = $post->post_parent;
} else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
$parent = $post->ID;
}
echo "<li class=\"section-title\"><a href=\"" . get_permalink($parent) . "\">" . get_the_title($parent) ."</a></li>";
if ($children) {
echo $children;
} ?>
What I'm trying to do now, though, is have a separate navigation bar when there are grandchildren pages that only shows up on those grandchildren pages. In essence the same thing as what I have above but up a generation.
I tried using get_page_children since wp_list_pages doesn't seem to allow multiple child_of parameters to be passed (or a grandchild_of variable). I tried using the code below, but it doesn't work.
<?php
if ($post->post_parent) {
$children = get_page_children($post->post_parent, "");
if ($children) {
$grandchildren = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
}
}
if ($grandchildren) {
echo $grandchildren;
}
?>
What's the easiest way to move my working parent-child relationship up to child-grandchild pages?
ThankS!