• Hi everyone,

    I’m looking to add a page specific menu in wordpress.

    My site consists, among other pages, of three special pages which have children and grandchildren in the page structure in WordPress. So three pages with three levels in all.

    What I want to do is to display a different custom navigation menu depending on page family on all ancestor pages.

    I have succeeded with displaying a specific navigation menu on parent pages and their children, but not on grandchildren.
    I have used:

    if (is_tree(page-id)) {
    // stuff
    }

    to include and display each specific navigation menu.php, but as mentioned, it is not working for grandchild pages.

    Is there any way to display it on the full family tree?

    Looking forward to receiving suggestion for a solution. Thank you for your help!
    Anne.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Don’t know if this will help Anne, but I had a similar issue where i had to display a menu using Advanced Custom Fields in the header. I am also using the Max Mega Menu plugin so I can generate a menu shortcode.

    This is what I did anyway. You might be able to adapt it. I made a text field called ‘page_menu’ and applied it into the top level parent page using ACF. The text field should contain the Max Mega Menu shortcode.

    Then I applied this code into my template and the menu appeared everywhere on parent, child, children, grandchildren, great grandchildren, great great grandchildren etc etc

    if ( 0 == $post->post_parent ) {
    the_field(‘page_menu’);
    } else {
    $parents = get_post_ancestors( $post->ID );
    echo do_shortcode( get_field (‘page_menu’, end ( $parents ) ) );
    }

    Thread Starter Anne SM

    (@anne-sm)

    Hi Nick,

    Thank you for taking the time to reply. Unfortunately this is not doing the job for me. I can display the mega menu on parent and child pages, but it is not working on grandchildren etc. Also it only allows me to have one specific page menu, not three different page menus on each ancestor tree as I was looking for.

    I will try instead to make templates including each menu for each of the three parent pages and see if I can get all children and grandchildren to inherit the menu. So far no luck though…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include menu on all child and grandchild pages of a specific parent page’ is closed to new replies.