How to get correct URLs in network wide menu (Multisite)?
-
I'm using this function to switch to my main website's navigation and display it on all sub sites in my multisite network. Ideally the links should have the following format: http://www.mysite.com/navigation-link but on the sub-sites the urls are http://www.mysite.com/subsite/navigation-link Obviously these pages don't exist so it's just showing a blank page. Any idea how I could make sure the urls are like the first example and how I might incorporate that into my function? function wp_multisite_nav_menu() { global $blog_id; $args = array( 'menu' => 'Main Menu', 'theme_location' => 'main-nav' ); $main_blog = 1; $main_blog = absint( $main_blog ); if ( !is_multisite() || $blog_id == $main_blog ) { echo wp_nav_menu( $args ); return; } else { switch_to_blog( 1 ); echo wp_nav_menu( $args ); restore_current_blog(); } }
-
Answer:
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 = array( 'menu' => 'Main Menu', 'theme_location' => 'main-nav' ); switch_to_blog( 1 ); echo wp_nav_menu( $args ); restore_current_blog(); }
Andrew Chappell at WordPress Visit the source
Related Q & A:
- How to get correct URL in HTTP header?Best solution by Stack Overflow
- How to redirect custom urls to some local IPs with pfSense?Best solution by stackoverflow.com
- How to I redirect URLS with special characters in htaccess?Best solution by Server Fault
- How to get the name of the currently connected WiFi network?Best solution by Stack Overflow
- How to get the toxic menu again on ps2?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.