You can use has_nav_menu()
to check to see if the location has one assigned to it. If it does, use wp_get_nav_menu_items()
to duplicate the menu, then assign it to the location you register in your theme.
Here’s what I have in mind. It’s off the top of my head and will need more code and testing, but hopefully it’s a good start for you:
function wpse112672_menus() {
if( has_nav_menu( 'old_theme_menu_location' ) {
$old_menu = wp_get_nav_menu_items( 'old_menu_id' );
register_nav_menu( 'new_theme_menu_location' );
$new_menu = wp_nav_menu( $args );
return $new_menu;
} else {
return wp_page_menu();
}
}
Related Posts:
- Add separator to admin submenu
- Custom Admin Menu Order
- SlideDeck 2, make back-end visible for admins only
- Changing the Order of Admin Menu Sections?
- Adding an Arbitrary Link to the Admin Menu?
- Does Extending Multiple Nav_Menu_Walkers Allow Nested Menus?
- wp_nav_menu remove class and id from li
- Renaming a WordPress Admin Menu
- Any official way to create an admin theme?
- How do I fix this error: Warning: invalid argument supplied for foreach()?
- How to add menu to Dashboard that can be viewed by all users
- Menu is not visible in appearance
- One site, 2 distinct sections: two different top nav menus?
- Move admin menu at the end
- How can I disable parent menu item links?
- Organizing by super-categories (or nested categories)?
- Nav menu items disappearing (but not immediately)
- Hide pages depending on role
- How to display custom post meta in the appearance->menus page
- wp_nav_menu custom walker – child items
- How can I get an array/list of all current WordPress Admin Menu items?
- wp_nav_menu doesn’t generate parent/ancestor classes
- how to only add a top-level admin menu without it creating a sub-level-menu
- Add static item to wp_nav_menu
- How to get wordpress nav menu outside of wordpress system?
- Add nav menu CSS class to body
- Change HTML structure for custom menu in sidebar
- Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?
- Remove Metabox from Menus screen
- Sort wp_nav_menu() by menu order
- Current menu item
- Disabling ‘posts’ in Appearance > Menus
- Hiding Admin Page While Keeping Menu Expanded
- remove everything from wp_nav_menu
- How to add wechat (weixin) link to navigation menu?
- Admin only menu/page
- Get admin menu link
- Best way to customise wp_nav_menu [duplicate]
- Adding all sub-pages to the menu manager
- Hook for number of items in Appearance > Menus > CustomPostType > View All [duplicate]
- Filter for Admin Nav Menus Drop Down
- How to add custom classes to more than one separate menu’s a link in wordpress?
- How do I separate link levels in a custom menu walker?
- Limit the menu child levels under “admin > appearance > menus”
- Hard-coding custom menu elements for menu manager
- Admin menu structure
- Appearance Menus Screen – menu item drop down menu not functioning
- Adding an admin menu page showing the link twice – how to solve this?
- pull non-wp site into content area of wordpress -or- pull wp header into non wp site?
- Help with walker for nav
- Create custom page and add it in nav menu by code
- Using my WordPress menu on another platform
- Remove a menu sub-item
- How to add html attributes to the “ul” html tag with “wp_nav_menu” function?
- Using _s theme, menu changes do not affect header menu
- Limit User Iinterface for Admin?
- Admin-ajax.php 500 error when Add to menu is clicked in admin
- Make pages visible to only logged in members
- Can I have custom post types in “Add menu items” on in the Admin > Appearance > Menu
- Add Labels to Admin Menu ( How To )
- How can I make a menu link visible only to admins (without plugins)?
- Stop Expansion of Top Level Menu in the WordPress Admin Sidebar
- Adding top level items in the admin menu that link to a post
- How to get submenu of admin menu?
- How to undo the last changes to a custom menu?
- Strange menu behaviour wordpress admin [duplicate]
- Adding CSS-class to WordPress Menu in backend
- Menu deletes all items and position – wordpress bug?
- Plugins & Setting Menu Items Removed From Admin Panel
- Filter to hook into menu items and add a custom attribute
- I can’t add more pages to menu – menu delete pages
- Responsive menu on genesis theme [closed]
- add_menu_page does not render the expected result
- Admin Menu Hack (Left side in Dashboard)
- Lost admin “manage_link” capability WordPress. No “Links” menu item in admin menu
- How to open a lightbox form from a navigation menu item
- How to create this kind of sub-menu in new line?
- Hide custom menu when when no menu selected
- Admin menu in different languages
- Need to remove the admin menu item from a be theme in wordpress
- Add category label for appearance > menus items
- Removing wp admin menu item on top bar of admin backend
- Add a data attribute to list item element in menu
- Links in new menu don’t work
- wp_is_mobile() inside js
- how to display wordpress navbar with top menu outside wordpress system
- Appearance > Menus
- Customizing label/title output of admin nav_menu selecter
- Is It Possible To A Link To The Homepage From The Admin Sidebar?
- Query for menus in backend (BE)
- List of WordPress menu item indices?
- Creating and populating custom nav menu (menu-item-position not working)
- custom rearranged menu with excerpt for selected children in sidebar.php
- wp_nav_menu in 3.7 add name class nav navbar-nav
- Menu – custom structure
- How can I disable sorting/dragging of a menu item in the custom menu admin?
- custom walker to add iconfont to wp_nav_menu
- How to change the markup created by menu item only on chosen items?
- After WordPress 4.8 upgrade, wp_nav_menu() string search / replace not working
- How to change WP menu item type?