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.

2 Answers 2


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".

  • Thank you so much for the detailed explanation! It worked like a charm.
    – Smos
    Commented Sep 2, 2013 at 19:22
   if (is_user_logged_in())
       // echo the link
       // Dont echo the link

Doesn't require a plugin.

  • How would this help when dealing with a menu?
    – s_ha_dum
    Commented Sep 1, 2013 at 18:55
  • @s_ha_dum Are you sure? codex.wordpress.org/Function_Reference/is_user_logged_in
    – Twifty
    Commented Sep 1, 2013 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
    Commented Sep 1, 2013 at 19:08
  • @s_ha_dum Ahh, nice catch, I took his 'menu' in the sense of sidebar/navigation menus.
    – Twifty
    Commented Sep 1, 2013 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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