Show Different Menus to Logged in Users in WordPress

function my_wp_nav_menu_args( $args = '' ) { if( is_user_logged_in() ) { $args['menu'] = 'logged-in'; } else { $args['menu'] = 'logged-out'; } return $args; } add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
Go to Appearance » Menus, create two menus logged-in and logged-out.
After creating the menus, add this code in your theme’s functions.php file.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.