Skip to content

Instantly share code, notes, and snippets.

@thomaswilburn
Created November 20, 2014 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaswilburn/edf7bfe1e19066d310be to your computer and use it in GitHub Desktop.
Save thomaswilburn/edf7bfe1e19066d310be to your computer and use it in GitHub Desktop.
Global menu for Wordpress that isn't a huge goddamn hack
<?php
//function for getting a global menu
//that caching plugin really was ridiculous, wasn't it?
if (is_multisite() && !is_main_site()) {
switch_to_blog(1); //should send us to the main site temporarily
}
wp_nav_menu("menu_id"); //get the nav menu from the main site context
if (is_multisite() && ms_is_switched()) {
restore_current_blog(); //revert to the network site if we switched it above
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment