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)
- php page not found for plugin options menu
- Delete mobile menu button [closed]
- html generated by theme exist but doesnt appear in browser
- Changing page URL and connect newsletter to MailChip
- add tabs in rdp-plugin/includes/settings.php and get settings saved
- Enabling plugin failed because MySQL user do not have CREATE permissions
- Dynamic admin submenu
- wp_editor content in plugin options page
- Center and hide overflow of WP toolbar custom links
- How to remove admin main menu name repetition
- Custom Permalink Plugin and Current Page/Ancestor in Menus
- options creation for plugins
- wp-custom-menu filter removes the current_page_item class
- add_action does not call the function
- How to create an option page for this simple plugin
- How to use my menu PHP code as sidebar?
- get_option error plugin development
- Creating Featured Content Boxes
- Gathering and logging data from a plugin: how to do it without race conditions?
- Update a core option from plugin settings page
- WordPress error: Options page Setting_ not found in the allowed options list
- Can I use register_settings and unregister_setting once the settings page has loaded?
- update_option_{$option} not showing old value
- Hide a Menu Item on Login
- Updating options into the wp database performance
- How to get menu location in wp_update_nav_menu hook
- Can deactivating a plugin sometimes “reset” settings within that plugin?
- Allowed memory size exhausted problem
- PHP script from functions php is loaded via admin-ajax to div…and the result is 0, not the desired content
- Change the style of h1, h2, only in post entry
- Plugin getting Cannot modify header information errors
- Ambrosite Next/Previous Post Link Plus or WP next_post_link to cycle through top level category
- How to add options to the plugin page?
- Saving widget options from class method
- How to prevent plugins from sniffing/stealing other plugins’ options?
- Default plugin config to override wp_options?
- Progmatically adding menu links to the default (Top) or Footer menu
- get_option / wp_localize_script Not Working in OOP Plug In
- 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
- Plugin scheduled event not working
- Update WP option by plugin
- How to save plugin custom settings page fields
- Changing location of “About me” section
- How to reinstate previously saved option?
- Need to revert to an older version of wordpress
- How (or where) do I get wordpress plugin update download link?
- Adding option values as an array using a multi selectable select box
- Store plugin page content in wp_options?
- WordPress Custom Menu Admin helper plugin
- Every time I save my plugin options it erases another plugin options
- 2 wordpress site same database
- Changing plugin options from theme functions file?
- 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?
- Dropdown menu on click change
- Localise settings section headline
- navigation among single posts
- How do i specify a url to which to redirect the user after he logs out from facebook?
- Need to add/remove group of options and display them as rows
- Multisite Plugin – Access options (wp_options) on child sites
- Adding a pagenavi to function for displaying bookmarks
- How to get values from network settings panel?
- How to add a custom form to a plugin’s setting page
- update_option creates an option, which empties on a blog reload
- I cannot include a file in my plugin settings page
- Using call_user_func() within add_settings_section() within a Class
- What is the most efficient way of adding additional functionaliy for admin only
- Color Picker UI in admin is not correct
- How to make sure settings are not lost when plugin is updated?
- Button and Countdown overlapping mobile menu
- Navbar affect loading all products
- wp_options not returning value for logged out users?
- How to save Setting pages data to the database?
- Slideout submenu in mobile
- Save log for imports in WordPress database – options-table, custom post type or other place?
- Managing and deleting transients with dynamically generated transient names
- how to show new field if option selected?
- Display posts by alphabetical order
- Problem with MEMCACHE and Redis with wp_options
- Mobile Menu and Mobile Sidebar missing
- WP Forms not displaying,becomming an fatal error
- Creating an array from form inputs before it is posted to the options database
- WordPress Dashboard add user password not working, etc
- Changing the CSS with a plugin
- Load google font script based on optgroup label selected