A recently developed navigation scheme called for a horizontal menu with a dropline for the second level pages and a third level page list in the sidebar. Although there are lots of sidebar widgets for subpages, it took a bit of digging and cobbling together of information from different sources to implement this hybrid scheme.

The first step was to add a function to identify the grandchildren.

function is_grandchild_page() {
	global $post;
	 if ( is_page() && (count(get_post_ancestors($post->ID)) >= 2) ) {
	 	return true;
	 }
}

Here’s the code:

<?php if ( is_grandchild_page() ) { ?>
<?php
if($post->post_parent) {
$children = wp_list_pages
("title_li=&depth=1&child_of=".$post->post_parent."&echo=0");
$titlenamer = get_the_title($post->post_parent);
} else {
$children = wp_list_pages
("title_li=&depth=1&child_of=".$post->ID."&echo=0");
$titlenamer = get_the_title($post->ID);
} if ($children) { 
?>
<h2> <? echo $titlenamer ?> </h2>
<ul> <?php echo $children; ?> </ul>
<?php } } ?>