You just need the last part of your function where you switch to blog 1 and get the menu.
function wp_multisite_nav_menu() {
$args = [
'menu' => 'Main Menu',
'theme_location' => 'main-nav'
];
switch_to_blog( 1 );
echo wp_nav_menu( $args );
restore_current_blog();
}
Related Posts:
- Difference between the_permalink() and get_permalink() function
- Prevent “main” WPMU site_url() being returned in functions
- Use author author display name in permalink structure for pages and posts
- paginate_links() don’t properly work in search.php?
- Remove Container Element From wp_nav_menu() Markup
- Refresh page after form action
- Implementing DNS Prefetching with WordPress
- Breadcrumbs showing Parent and Child Pages
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- Convert hyphen to underscore in permalinks
- Different functions file for each site in multisite installation?
- Adjust which tempalte a page uses with a function?
- Generate permalinks
- Delete pages and Create default pages for all new network sites
- Multisite, either change the name of sample-page or create new page
- Disable shortlinks like ?p=1234 to prevent scraping
- Loop (iterate) through Multi-Site sub-sites (blogs)?
- Global functions on WPMU
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- restore_current_blog required after switch_to_blog, if I use that in a function?
- Breadcrumbs – Exclude Child Categories
- Manipulate Permalink
- How do I create page navigation linking to each H2 within the page? [closed]
- Run function when WordPress new multisite is created or ACF field is updated
- Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
- Conditional Gravity Forms filter in WordPress Multisite
- Multisite Ajax serialize return error [object Object]
- Categories as main menu items and subcategories as nested lists
- Creating new blog on multisite programatically without hacks?
- Where to add the permalink in this function?
- Multisite 404 on pages – rewrite error breaks database
- paginate_links() don’t properly work in search.php?
- Has is_archived() for sites in a multisite changed with WP 4.7?
- append to existing parent theme function
- Function that outputs second theme url
- How to fix get_the_category function returning incorrect slug?
- Test if a post exists by category and date
- retrieves menu and converts it to a readable array
- Secondary Menu and Logged In Users
- How to properly refresh page after form action?
- dynamic site link for future migration in echo do_shortcode()
- Default Nav Highlight
- Setting Permalinks in wp_config or functions file?
- Multiple navigation menu in same location
- Redirect to post after publish or update a published post
- wp_get_attachment_image_src returns image on main domain, false on subdomain
- functions.php return custom text
- Dashboard blocker on network multisite for specific user roles
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- Members only function, but allow account activation [solved]
- How to add extra value to permalink
- Bizarre Child Menu Issue on WP Site
- How Can I Create a Friendly Slug for a Dynamic Page?
- Add #primary at the end of navlink permalinks on single posts
- How to automatically add counted number to navigation menu items?
- Competing Login Redirects – Need to be Combined?
- Adding a class to the body of an inactive site using multisite
- Filter posts on new page
- How to add widget in main menu
- Setting Active Nav item (of Pages) when you are on a Post with Category
- Check if excerpt is empty at loop-portfolio
- Exclude javascript in certain page url and all following url’s after forward slash
- Undefined offset: 2
- Run function from parent on child site
- Ads Only at one website inside multisite network – code error
- Different ads on every website on multisite environment
- Is it possible to remove the main rich Text box editor?
- Calling a function from functions.php in header [closed]
- Dynamically add sub-categories to any category in the menu
- Adding Google Analytics to footer selectively
- I changed “Howdy” in the admin bar in the dashboard, but when I’m viewing the site it still says Howdy!
- Template tags vs get_template_part() vs functions.php
- Custom logo sizes for multiple logos
- how to change link of some wordpress pages
- When to use an if statement after get_posts?
- Programmatically Create Category and sub Category
- wp_get_attachment_image function size argument not working if I also add a custom class
- Get_template_part inside a folder
- Passing values from a widget to a function within a plugin
- Contact Form 7 – Delay auto responds
- Replace a menu with widget or a custom template file programmatically
- Is there a WP function to get taxonomy name from taxonomy_term_id?
- Function added using `add_action()` not being called
- How to change this simple code so that it sends the email notification after payment in WooCommerce?
- Allowed memory size of 33554432 bytes exhausted (tried to allocate 9967617 bytes) in …\wp-includes\functions.php
- What happens to the text in functions.php file outside of the php enclosure?
- WordPress can’t get jquery/unslider to work
- template_redirect action only firing if logged in
- Unable to use get_page_by_title() more than once per page?
- Featured Image and Tags problem
- Advanced method to control cache of enqueued style/script
- large image size of 1440×1440 not pulling 2x of 2880×2880 image
- I’m getting invalid taxonomy in init action
- Only seems to be displaying one child when there are supposed to be multiple
- Rest API User Levels
- adding google analytics via echo or between tags
- Meta Box value not been pulled in
- How to Update User Meta Field other than from profile?
- More link – not text
- PHP Notice: Function is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false