Bainternet’s solution will definitely work, but it you want to use the page slug instead of ID you could put this in your functions.php file:
// GET PAGE ID FROM THE SLUG, HELPER FUNCTION FOR IS_TREE
function get_ID_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
return null;
}
}
// DETERMINE IF A PAGE IS IN A DESCENDANT TREE
function is_tree($pid) { // $pid = The ID of the page we're looking for pages underneath
global $post; // load details about this page
$pid = get_ID_by_slug($pid);
if( is_page() && ($post->post_parent==$pid || is_page($pid) ) )
return true; // we're at the page or at a sub page
else
return false; // we're elsewhere
};
And then use this for the conditional statement in your sidebar.php or whatever:
<?php if ( is_tree('advice') ) {
wp_nav_menu( array( 'theme_location' => 'advice-menu' ) );
} elseif ( is_tree('another-page-slug') ) {
wp_nav_menu( array( 'theme_location' => 'another-page-menu' ) );
} ?>
That will return any page that is within the ‘tree’ – both the parent page itself and any children below it. Hope this helps, best of luck!