Skip to content

Instantly share code, notes, and snippets.

@angeliquejw
Forked from sareiodata/gist:4307554
Created October 18, 2013 00:56
Show Gist options
  • Save angeliquejw/7034866 to your computer and use it in GitHub Desktop.
Save angeliquejw/7034866 to your computer and use it in GitHub Desktop.
WP menus that switch based on if user is logged in or not
/**
* Register menus in functions.php
*/
register_nav_menus( array(
'logged-in' => __( 'Logged-in Menu Area', 'yourtheme' ),
'visitor' => __( 'Visitor Menu Area', 'yourtheme' ),
));
/**
* Include in header.php or wherever you want to display menu
*/
if (is_user_logged_in()){
wp_nav_menu( array(
'menu' => 'Logged In Menu',
'container_class' => 'logged-in-menu',
'theme_location' => 'logged-in'
));
} else {
wp_nav_menu( array(
'menu' => 'Visitor Menu',
'container_class' => 'visitor-menu',
'theme_location' => 'visitor'
));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment