How to display different menus for logged-in and logged-out users in WordPress

Written by Ian Carnaghan · 18 sec read >

Add the following snippet of code in your theme to the location where you would like the menu’s to be displayed.

if ( is_user_logged_in() ):
 wp_nav_menu( array( 'menu' => 'Loggedin' ) );
 wp_nav_menu( array( 'theme_location' => 'primary' ) );

Basically, what the code above does, it checks if the user is logged-in and then displays the LoggedIn menu, you may replace LoggedIn with your menu name.

If the user is not logged-in we display the primary menu.

Last Updated On April 06, 2018
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. Profile

Leave a Reply

1 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Sam Mastovich Recent comment authors
newest oldest most voted
Notify of
Sam Mastovich

Hey Ian,

Thank you for your straightforward writing style. I appreciate the direct tips and the fact the you provide all of the information people need in an effective and efficient manner. Thank you!