Support » Plugins » [Hack (is_page) to include child pages]

  • Hi,

    I am using an IF statement to display different menu’s for different pages. So each menu item links to a child page associated with page which you are on. For Example:

    Brand Page 1:(Main Page)

    • Events (Child Page of Brand Page 1)
    • Info (Child Page of Brand Page 1)
    • Contact (Child Page of Brand Page 1)

    So here is the code which I use for the menu’s:

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser. ]

    if (is_page('brand1')){
    wp_nav_menu(array('sort_column' => 'menu_order', 'menu_class' => 'main', 'theme_location' => 'brand1-menu'));
    } elseif (is_page('brand2)) {
    wp_nav_menu(array('sort_column' => 'menu_order', 'menu_class' => 'main', 'theme_location' => 'brand2-menu'));
    } elseif (is_page('brand3')) {
    wp_nav_menu(array('sort_column' => 'menu_order', 'menu_class' => 'main', 'theme_location' => 'brand3-menu'));
    } ?>

    So this works great when I am on the main brand page but not on the child pages… Any idea how to add the child pages?

    Thanks a lot!

  • The topic ‘[Hack (is_page) to include child pages]’ is closed to new replies.