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
- Custom User Role not working
- Custom permalink for post of one category
- How to Programmatically Replace Characters in WooCommerce Product Slugs?
- Load jquery only for certain pages in the backend
- Events: Check for other event with same start date and category [closed]
- Update user meta of author when post content is viewed
- Filtering out the #more anchor link that gets produced by
- How to show only blog-domain instead of the whole permalink in the loop
- comments_popup_link without echo?
- Remove adjacent_posts_rel_link under 3.2?
- Registration Hooks don’t appear to be working
- Can’t filter wp_get_attachment_link
- How to load parent theme template parts in child theme
- How to create an onclick event on an image in a post?
- Impossible to call wordpress function inside an include?
- How do you Permanently Delete Sidebars
- Which functions/classes are available during SHORTINIT?
- WordPress Page Restrict
- Remove category from url
- Function added using `add_action()` not being called
- Excerpts are not displayed by a shortcode on category pages
- ‘Attempt to modify property of non-object’ warning
- Add a unique class to HTML tag/element
- Conditional functions.php on page template
- Do we have to use ftp to recover from a bad functions.php edit?
- Getting comment count per post not working
- Functions.php Problem
- How can this crude function be improved?
- WordPress function saves a post twice and updates all posts
- What does this code do? (Injected code hacked)
- Change CSS for logged in users
- current_time(‘timestamp’) seems to be different from the real current time
- Wp admin – Set default value to 999 in comments
- Removing specific menu items?