You can use the wp_nav_menu_args
filter ( Codex reference ) to set a theme location to use a specific menu.
Example:
function test_wp_nav_menu_args( $args="" ) {
// only set menu for the primary navigation menu.
if ( $args['theme_location'] != 'primary' ) {
return $args;
}
// change {main-menu} to be the slug of the menu you want to set.
$args['menu'] = 'main-menu';
return $args;
}
add_filter( 'wp_nav_menu_args', 'test_wp_nav_menu_args' );
Related Posts:
- What’s the easiest way to duplicate an entire navigation menu?
- How to make a plugin auto-add item to nav menu
- Popup Maker nav menu item not working
- Easiest way to add dropdown to a page
- Redirect to another page using contact form 7? [closed]
- How can I add a fixed vertical menu to my site? [closed]
- WordPress site hamburger menu toggle not working
- WP Super Large Menu Problem
- How to build a navigation menu for long-form texts like this one
- How can I create a navigation menu in the sidebar that can also act like a slider?
- Prevent primary navigational menu from expanding during page load (WordPress / Astra Theme)
- ‘Global’ settings page for multisite plugin
- Contact form 7 select box different value-text than content-text in option [closed]
- How to find out if option exists but is empty?
- Network-Wide Plugin Settings Management
- How to create a Page alias in WordPress
- wp_nav_menu(); Outside WordPress installation
- How do I make a wordpress plugin with menu item etc
- Custom options page checkbox will not save, despite working with text
- Settings API – input always updates over validation
- Creating a menu page in a Object Oriented developed plugin
- Restore a Plugin’s Default Settings
- add action wp_head not working
- How to debug register_setting callback function
- Include Max mega menu Plugin into theme
- How use %like% in sql statement wordpress
- Default Plugin Settings Not Writing to Database
- Update Option Error: Notice: Undefined index
- Wondering what these multi-colored extra pages are?
- Serialize data for wp options
- Menus, but not by theme location
- Why slash is removed after domain?
- How to add a default value to get_option if it’s used as a variable?
- Update menu when saving settings
- Get plugin option in another PHP file
- Image upload and other options in the same plugin settings form?
- Creating a nav menu
- looking for navigation plugin (accordion) [closed]
- How to get the element ID from new menu list that added with add_filter()?
- Enabling plugin failed because MySQL user do not have CREATE permissions
- Center and hide overflow of WP toolbar custom links
- How to remove admin main menu name repetition
- options creation for plugins
- Creating Featured Content Boxes
- WordPress error: Options page Setting_ not found in the allowed options list
- Hide a Menu Item on Login
- Allowed memory size exhausted problem
- Saving widget options from class method
- OceanWP settings are missing from Add New Post [closed]
- $pages = get_pages(‘child_of=’.$post->ID); Why arguments are concatenated?
- Change in one place the data about the company, which are placed on several pages
- How to save plugin custom settings page fields
- How to reinstate previously saved option?
- Hook on creating a menu entry?
- Adding a theme option to the admin that lets me turn on/off a javascript file
- How to make a textarea accept javascript in my settings apge?
- How do you add a settings page to another menu?
- Localise settings section headline
- navigation among single posts
- Button and Countdown overlapping mobile menu
- Navbar affect loading all products
- wp_options not returning value for logged out users?
- Slideout submenu in mobile
- Display posts by alphabetical order
- Problem with MEMCACHE and Redis with wp_options
- WP Forms not displaying,becomming an fatal error
- WordPress Dashboard add user password not working, etc
- I need to show side menu in wordpress
- Create survey that redirects to sidebar menu customized to answers
- Pagination (including title of each page) in a post for a long posts
- Circular Menu to show on pages
- Warning: sprintf(): Too few arguments in nav-menu-template.php
- Optimized PHP & WordPress settings for speed/performance?
- WP options plugin setting not saving the selected checkboxes
- Page Contents showing in Footer Area
- How to disable users to view Other pages
- How do I add a textarea (multirow) option to my WordPress plugin?
- Registered sidebar area is not shown from plugin.
- why my wordpress dont have toolbar like, plugin, themes and other?
- Header lists posts instead of showing primary nav menu
- database – multiple wordpress installations using same database – can they share plugin settings?
- WordPress update plugin through Dashboard/Plugins displaying error
- How to assign plugin to top level menu?
- Adding icons next to categories in wp_nav_menu
- get_option returning old value for non-admin users
- get Options value in “external” page
- Automatically add child pages to menu
- How change menu for each user in plugin?
- how to protect wordpress website
- how to change/remove/hide menu under installed plugins
- homepage olderposts link showing page not found
- Redirect url in plugin to somewhere else?
- How to activate/deactivate menu tab and keep the same id?
- How can I add different menus (different style menu) on each page?
- How to validate password length in wordpress
- Why plugin’s icon for the menu not found?
- My wp_update_nav_menu action is firing twice
- Neither update_option nor delete_option fires in deactivation hook
- How does one add numbers to an admin menu?
- move setting data from wordpress api to codestar freamwork