Hi! I have a site with the following set up:
Parent1
-Child1a
Parent2
-Child2a
-Child2b
Parent3
-Child3a
-Child3b
-Child3c
-GrandChild3c.1
-GrandChild3c.2
-Child3d
Parent4
Currently, when I am on a Parent or Child page, the submenu navigation lists the Child pages (see code below). When I am on a Grandchild page, the Grandchild pages are listed instead.
Is it possible to write a PHP "if" statement to not show this third tier of navigation or, ideally, if I were on GrandChild2c.2 page, to list the same navigation I would see if I were on Child2c?
I am using the following to display the navigation in my header.php :
<div id="menu">
<ul class="caps style<?php echo ($post->post_parent); ?> style<?php the_ID(); ?>"><?php wp_list_pages('include=7,9,11,12&sort_column=menu_order&title_li=&depth=1'); ?></ul>
</div>
<div id="submenu" class="style<?php echo ($post->post_parent); ?> style<?php the_ID(); ?>">
<?php
if($post->post_parent)
$children = wp_list_pages("sort_column=menu_order&title_li=&depth=1&child_of=".$post->post_parent."&echo=0"); else
$children = wp_list_pages("sort_column=menu_order&title_li=&depth=1&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
</div>