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 running multi-site, i have an activation file which looks like this....

//First check it make sure this function has not been done
if (get_option('this_has_run') != "yes") {

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

        // Check if Top menu exists and make it if not
        if ( !is_nav_menu( 'Navigation' )) {
            $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' => 'Login','menu-item-object' => 'page','menu-item-object-id' => get_page_by_path('login')->ID,'menu-item-type' => 'post_type','menu-item-status' => 'publish');

            wp_update_nav_menu_item( $menu_id, 0, $menu1 );
            wp_update_nav_menu_item( $menu_id, 0, $menu2 );

    //now that function has been run, set option so it wont run again
    update_option( 'this_has_run', 'yes' );

This is meant to run once on activation but its not happening. The Navigation menu is being set but the menu items are not being created.

Anyone any ideas?

share|improve this question
add comment

Your Answer


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

Browse other questions tagged or ask your own question.