WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The title pretty much explains itself, I'm looking for a way/plugin to hide the menu link to a specific page from users that aren't logged in.

share|improve this question
up vote 1 down vote accepted

No plugin or PHP code is needed to do this. If you look at your HTML body class, you will see that WP helpfully adds the class of "logged-in" for any users who are registered and logged into the site.

With this info along with the class name you give for the particular menu link you want to hide/show, you can draft a CSS rule that will hide that.

In your menu settings, first turn on CLASS field by going to the top right of your screen and clicking on "screen options" and check the box for CLASS fields. This will now show a class field for each menu item in your menu.

So for the menu you want to show/hide, add a class name such as "hide".

Then in your theme's CSS, you can add the following:

.menu li.hide { display:none; }
.logged-in .menu li.hide { display:block; }

So the above CSS says to hide the menu link with the class name of "hide" and if body class has "logged-in", then show it.

Of course you may need to change the CSS classname to suit your theme's CSS class name. For example yours may not be ".menu".

share|improve this answer
Thank you so much for the detailed explanation! It worked like a charm. – Smos Sep 2 '13 at 19:22
   if (is_user_logged_in())
       // echo the link
       // Dont echo the link

Doesn't require a plugin.

share|improve this answer
How would this help when dealing with a menu? – s_ha_dum Sep 1 '13 at 18:55
@s_ha_dum Are you sure? codex.wordpress.org/Function_Reference/is_user_logged_in – Twifty Sep 1 '13 at 19:01
is_user_logged_in is a perfectly good function but if this is a menu created by wp_nav_menu, or related menu functions, how does this code help? – s_ha_dum Sep 1 '13 at 19:08
@s_ha_dum Ahh, nice catch, I took his 'menu' in the sense of sidebar/navigation menus. – Twifty Sep 1 '13 at 19:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.