DEV Community

Cover image for How to show different menus to logged in users in WordPress
Chris Texe
Chris Texe

Posted on

How to show different menus to logged in users in WordPress

Sometimes we want to show different menus to logged in users than logged out users. Especially it could be useful when we have for instance a e-commerce shop. So how to do it?

Step 1 - create menu for logged in users.

Image description

Notice the menu ID - it will be required later. So menu for logged users should have a "LOGOUT" menu item.

Step 2 - create menu for non-logged in users:

Image description

Step 3

Open functions.php file which is in your theme directory and paste this code:

That's all! Now you can see you have two different menus depended on you are logged in or not.

Menu for non-logged in users

Menu for logged in users

Chris Texe

Top comments (0)