• For background: I have the parent theme active, but I am simultaneously using 2 child themes for 2 custom post types. This prevents me from using the Nirvana Settings GUI to set menus for the child themes.

    Presently, for pages utilizing my custom post types, the top and main menus are using wp_page_menu instead of the menu I’ve selected in the Nirvana Settings GUI.

    Inside theme-setup.php I see the below comment suggesting how to override this in a child theme.

    * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
    *
    * To override this in a child theme, remove the filter and optionally add
    * your own function tied to the wp_page_menu_args filter hook.

    Per https://developer.wordpress.org/reference/functions/wp_nav_menu/ I added ‘menu’ => ‘Main’, at the beginning of the array, because the menu I want to use is named Main.

    // TOP MENU
    function nirvana_top_menu() {
    if ( has_nav_menu( 'top' ) )
    wp_nav_menu( array( 'menu' => 'Main', 'container' => 'nav', 'container_class' => 'topmenu', 'theme_location' => 'top', 'depth' =>1 ) );
    }
    
    add_action ('cryout_topbar_hook','nirvana_top_menu',15);
    
    // MAIN MENU
    function nirvana_main_menu() {
    /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?>
    <div class="skip-link screen-reader-text">"><?php _e( 'Skip to content', 'nirvana' ); ?></div>
    <?php /* Main navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */
    wp_nav_menu( array( 'menu' => 'Main', 'container_class' => 'menu', 'menu_id' =>'prime_nav', 'theme_location' => 'primary', 'link_before' => '<span>', 'link_after' => '</span>' ) );
    }
    
    add_action ('cryout_access_hook','nirvana_main_menu');

    The above code now uses Main as my main menu on both child themes, but doesn’t use it for the top menu on either child theme. Would someone please point out what I’m missing? Thank you very much for your time.

  • The topic ‘Defined Main Menu for child in theme-setup.php, but Top Menu won't update.’ is closed to new replies.