Skip to content

Instantly share code, notes, and snippets.

@iamshanto
Created January 20, 2015 10:27
Show Gist options
  • Save iamshanto/7eac27d86dff0dcd67e0 to your computer and use it in GitHub Desktop.
Save iamshanto/7eac27d86dff0dcd67e0 to your computer and use it in GitHub Desktop.
Wrodress multisite menu
$slot = 1;
function ra_wp_nav_menu_filter( $content, $args ) {
global $slot;
$locale = get_locale();
$registered = get_registered_nav_menus();
$current = array_slice( $registered, absint( $slot - 1 ), 1 );
if( empty( $current ) || empty( $current[$args->theme_location] ) ) {
return $content;
}
if( is_main_site() ) {
set_site_transient('multisite_site_menu_'.$locale, $content);
} else {
$content = get_site_transient('multisite_site_menu_'.$locale);
}
return $content;
}
add_filter( 'wp_nav_menu_objects', 'ra_wp_nav_menu_filter', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment