I struggled with this same thing. Luckily, I was just able to solve it since it was hard to find solutions online. This post helped me immensely...
What I did was use his breadcrumb functions and put them in my functions.php
function get_parent_id ( $child = 0 ) {
global $wpdb;
// Make sure there is a child ID to process
if ( $child > 0 ) {
$result = $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE ID = $child");
} else {
// ... or set a zero result.
$result = 0;
}
//
return $result;
}
function get_ancestor_ids ( $child = 0, $inclusive=true, $topdown=true ) {
if ( $child && $inclusive ) $ancestors[] = $child;
while ($parent = get_parent_id ( $child ) ) {
$ancestors[] = $parent;
$child = $parent;
}
// If there are ancestors, test for resorting, and apply
if ($ancestors && $topdown) krsort($ancestors);
if ( !$ancestors ) $ancestors[] = 0;
//
return $ancestors;
}
Then in my header I checked to see if the pages top-most ancestor matched my pages ID. So first I added this to header.php:
<?php
$ancestors = get_ancestor_ids($post->ID, false);//call to function in functions.php
$grandparent = $ancestors[1]; // find the grandparent
?>
Then on my link to a page my code would look like this:
<?php if ( is_page('about') || $grandparent == '2' || $post->post_parent == '2' ) { echo " class=\"active\""; } ?>
I imagine you don't need to also have the $post->post_parent in there since the grandparent would just be the parent when you're only one level deep...
Hope this helps!