Dynamic or variable home link in shared primary nav – MU
-
I’m using a single primary nav across a network of sites by switching the blog id before calling for the menu–then switching back to the initial blog id for everything else.
However, I need one more refinement. For subsites, the home link in the primary nav needs to point to the current blog–not to the root website, which is where the primary nav is coming from.
Here’s the live example:
Root website–www.adoptaworker.org
Here the home button on the primary nav needs to point to https://www.adoptaworker.org, which it currently does–so no problem here.Subsite–www.adoptaworker.org/356-00125/
With this adopted worker subsite, the home button on the primary nav needs to point to https://www.adoptaworker.org/356-00125/, but everything else in the primary nav would continue to come from the shared network nav from the initial blog id.Here’s the code I’m using to share the primary nav across all the subsites:
//store the current blog_id being viewed global $blog_id; $current_blog_id = $blog_id; //switch to the main blog which will have an id of 1 switch_to_blog(1); //output the WordPress navigation menu wp_nav_menu( //add your arguments here ); //switch back to the current blog being viewed switch_to_blog($current_blog_id);
Thanks in advance for any suggestions.
- The topic ‘Dynamic or variable home link in shared primary nav – MU’ is closed to new replies.