Advanced Theme Switcher Resets Main Menu and simply lists all pages in menu

I’ve got the widget working. But each time I click a theme, the main menu setting is reset. I’ve followed your blog article (here: https://premium.wpmudev.org/blog/wordpress-different-theme-per-page-post/ ). Need a little support working out which variable to change.

  • MrHoneyfoot
    • WPMU DEV Initiate

    In one theme we have:

    <?php wp_nav_menu( array( 'theme_location' => 'main-navigation', 'menu_class' => 'nav-menu' ) ); ?>

    In another:

    <?php if (theme_get_option('general','enable_nav_menu') && has_nav_menu( 'primary-menu' ) ) {
    return wp_nav_menu( array(
    'theme_location' => 'main-navigation',
    'container' => 'nav',
    'container_id' => 'navigation',
    'container_class' => 'jqueryslidemenu',
    ));
    } ?>

    Finally the third:

    <?php wp_nav_menu(
    array(
    'container_class' => 'menu',
    'theme_location' => 'main-navigation'
    )
    ); ?>

  • MrHoneyfoot
    • WPMU DEV Initiate

    To be more specific, I was trying to get each theme to load the same menu when I switched. They weren’t. So I found the wpmudev article and switched the menu php in “header.php” files for each theme, trying to get them to match up. However each theme had a different way of declaring the menu. Turns out by the time I’d made my first post above, the first and third theme were matching. Switching between them worked. Only the second theme still spat out every page on the site, instead of the nice orderly menu.

    I isolated the offending section in the second file

    ( 'primary-menu' )

    So the lesson I learned was that

    has_nav_menu

    is basically analogous to:

    'theme_location'

    and all I had to do was change

    primary-menu

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.