I have a custom menu on a page:
<ul id="menu">
<li id="menu-item-148" class="menu-item menu-item-type-post_type menu-item-object-page current-page-ancestor menu-item-148 publish">
<a href="http://url/site/index.php/products/product-name/">Information<span class="circle">â¢</span></a>
</li>
<li id="menu-item-149" class="menu-item menu-item-type-post_type menu-item-object-page current-page-ancestor menu-item-149 publish">
<a href="http://url/site/index.php/products/product-name/register/">Register<span class="circle">â¢</span></a>
</li>
<li id="menu-item-150" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-150 publish">
<a href="http://url/site/index.php/products/product-name/support/">Support<span class="circle">â¢</span></a>
</li>
<li id="menu-item-151" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-151 publish">
<a href="http://url/site/index.php/products/product-name/downloads/">Downloads<span class="circle">â¢</span></a>
</li>
</ul>
Information is the parent page of the other 3
I have the following CSS, but it isn’t recognised at all, it doesn’t show up in fire-bug as being overridden, it just doesn’t seem to exist, but not sure why?
.current_page_ancestor > a,
.current-menu-ancestor > a { border: 1px solid red; color: red; background-color: blue; }
If I remove .current-menu-ancestor >
from the CSS then the styles effect all the links as it should
In your CSS change:
To:
But make sure to check out wordpress cusom menu walker.
It will have the sub items inside a new
ul
which is nicer and better for seo.I would use this instead, it’s also how I style WordPress menus in theme development.
Target the main navigation > child > child of child
CODEPEN DEMO
OR
CODEPEN DEMO