Skip to content

Instantly share code, notes, and snippets.

@mspalex
Last active January 30, 2016 16:20
Show Gist options
  • Save mspalex/97aa0f1310be370976a0 to your computer and use it in GitHub Desktop.
Save mspalex/97aa0f1310be370976a0 to your computer and use it in GitHub Desktop.
Wordpress - Have different Menus for Logged In users
<?php
//This is the normal wordpress menu code
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_class' => 'primary-menu',
'menu_id' => 'primary-menu',
'container' => false
) );
?>
<?php
//This is the new code, where *MAIN* and *MAIN_ADMIN* are menu names
if ( is_user_logged_in() ) {
wp_nav_menu( array( 'menu' => 'MAIN_ADMIN' ) );
} else {
wp_nav_menu( array( 'menu' => 'MAIN' ) );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment