How do I show a different secondary navigation menu for each section of my website?

The first stage is to create a separate menu for each section of the site. Create three menus called ‘Reiki Basics’, ‘Practice & Study’ and ‘Courses’. Add all of the relevant pages to each menu.

To make these menus appear in the sidebar, add them using three separate ‘Custom menu’ widgets. If you check your site now, you will find that all of the menus appear on every page. You’re half way there.

To ensure that only the appropriate menus appear on the appropriate pages, you can use widget logic. You need to create a test to see if your custom menus should display or not. For example, you only want the first menu to appear if you are on any of the pages ‘Reiki Basics’, 1.1, 1.2, or 1.3.

There is no function built in to wordpress (that I am aware of) that will test this easily. The following snippet (from the wordpress codex) however will allow you to do this easily, giving you a new function, ‘is_tree’.

function is_tree( $pid ) {      // $pid = The ID of the page we're looking for pages underneath
global $post;               // load details about this page

if ( is_page($pid) )
    return true;            // we're at the page or at a sub page

$anc = get_post_ancestors( $post->ID );
foreach ( $anc as $ancestor ) {
    if( is_page() && $ancestor == $pid ) {
        return true;
    }
}

return false;  // we arn't at the page, and the page is not an ancestor
}

All you need to do now is to use the function is_tree( ‘id’ ) to see if the current page is the page, or is a sub page of the appropriate page. So for the first section, your test will look like this: is_tree( ‘499’ ).

Here is a screenshot to show how it works:

A screenshot to show how to use widget logic to add custom menus depending on the parent page

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)