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

I have a menu. It has two items:

  • the first is a link ("Index", www.domain.com)
  • the second one is a link to a category page

I have the requirement to remove the first link when I'm on the index page and remove the second link when I'm on that category.


share|improve this question
possibly using display: none; with the css selector for the current menu item ? – Michael Oct 17 '11 at 16:27
The problem was getting the current menu item. But it turns out wordpress puts anchor css class in the current item. – mist Oct 18 '11 at 0:45

You'll probally want to use WP Conditional tags and do something like this:

   //show home  menu
else if(is_page('mypage')){
   //show category menu for JUST that page
//show the menu for all other pages

What you do inside each conditional statement is up to you. Here are 3 solutions:

  1. Use CSS and hide a class <style type="text/css">menu-item-### {display:none;}</style> You'd want put this solution in your <head>
  2. Create 2 or 3 menus and then call each menu depending on which page the user is on
  3. Add and use the exclude hook as described here

This could be modified depending on your needs.

Hope that at least gets you going in the right direction.

share|improve this answer
It did, thanks :) – mist Nov 6 '11 at 12:32
up vote 0 down vote accepted

The code that this menu produces is this:

<ul id="dd" class="dd">
  <li id="menu-item-142" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-142">
    <a href="http://www.domain.com">Index</a>
  <li id="menu-item-102" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-102">
    <a href="http://www.domain.com/?page_id=82">Categories</a>

I fix it adding this to the css file:

#dd .current-menu-item {
   display:none !important;

Wordpress is kind enough to add anchor css styles that can be used. i have the #dd prefix so that this only works on this menu and not all the others.

Hope this helps.

share|improve this answer
This would only work if the only two pages were the Home and Cat page. The OP made it sound like they may have more than the two pages. For example: If i had a "contact" page this would hide that from the menu when on that page. – BandonRandon Oct 18 '11 at 5:51
@BandonRandon, that is exactly what I want. – mist Nov 6 '11 at 12:28

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.