Skip to content

Instantly share code, notes, and snippets.

@jpmarchand
Last active January 20, 2016 19:19
Show Gist options
  • Save jpmarchand/be1db715374c20ea5695 to your computer and use it in GitHub Desktop.
Save jpmarchand/be1db715374c20ea5695 to your computer and use it in GitHub Desktop.
Show a different navigation menu to logged-in users in WordPress. Source: http://www.wpbeginner.com/wp-themes/how-to-show-different-menus-to-logged-in-users-in-wordpress/
<?php
//* Show a different navigation menu to logged-in users in WordPress
function prefix_show_different_menu($args = '') {
if (is_user_logged_in()) {
$args['menu'] = 'logged-in'; // Navigation menu's name when users are logged-in
}
else {
$args['menu'] = 'logged-out'; // Navigation menu's name when users are not logged-in
}
return $args;
}
add_filter('wp_nav_menu_args', 'prefix_show_different_menu');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment