Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am setting my navigation menu up using the following snippet in my functions.php.

add_action( 'init', 'add_menus' );
        function add_menus() {

                register_nav_menus(
                    array(
                        'main_nav' => 'Main Navigation',
                        )
                    );

$new_menu_id = wp_create_nav_menu( 'Navigation' );                  
$menu1 = array('menu-item-title' => 'Home','menu-item-object' => 'page','menu-item-object-id' => get_page_by_path('home')->ID,'menu-item-type' =>     'post_type','menu-item-status' => 'publish');         
$menu2 = array('menu-item-title' => 'Register','menu-item-object' => 'page','menu-item-object-id' => get_page_by_path('register')->ID,'menu-item-type'     => 'post_type','menu-item-status' => 'publish');         
$menu3 = array('menu-item-title' => 'Login','menu-item-object' => 'page','menu-item-object-id' => get_page_by_path('login')->ID,'menu-item-type' =>     'post_type','menu-item-status' => 'publish');

// add a menu item to that new menu
wp_update_nav_menu_item( $new_menu_id, 0, $menu1 );
wp_update_nav_menu_item( $new_menu_id, 0, $menu2 );
wp_update_nav_menu_item( $new_menu_id, 0, $menu3 );

// set our new MENU up at our theme's nav menu location
set_theme_mod( 'nav_menu_locations' , array('main_nav' => $new_menu_id ) );
}

When I create a new multi-site it generates the menu and the menu items, however it does not assign the Theme Location as set by:

set_theme_mod( 'nav_menu_locations' , array('main_nav' => $new_menu_id ) );

If I delete the menu and then refresh it does then assign it correctly, any idea what is going on?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.