Skip to content

Instantly share code, notes, and snippets.

@jpmarchand jpmarchand/show-different-menu.php Secret
Last active Jan 20, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.