Menu item not created on theme activation
The value of $menu_id is not initialized if the menu already exists. So, if on theme activation, $menu_exists is true, $menu_id will never be set to a value and this line should produce a PHP warning: $locations[$menulocation] = $menu_id; You could try adding it like this: if ( $menu_exists ) { $menu_id = $menu_exists->term_id; } … Read more