I have this code

<div class="mainmenu">
<ul>
 <li><a href="#">Home</a></li>
 <li><a href="#">About</a></li>
 <li>
    <a href="#">Service</a>
    <ul>
     <li><a href="#">Domenstic</a></li>
     <li><a href="#">International</a></li>
    </ul>
 </li>
 <li><a href="#">Contact</a></li>
</ul>
</div>

I’m trying to use .current-menu-item wordpress class and i want the font style of .current-menu-item be italic and if the current menu item is a submenu i want both submenu and parent menu’s a tag have the italic font style. For example in the above code if the current menu item is Domestic i want both Domestic and it’s parent Service be italic, not just Domestic.

1 Answer
1

As i got the solution so i am posting it here. WordPress uses current-menu-ancestor and current_page_ancestor classes. So we can use them as below

.mainmenu .current_page_item > a,
.mainmenu .current_page_ancestor > a,
.mainmenu .current-menu-item > a,
.mainmenu .current-menu-ancestor > a {
  font-style: italic;
}

Leave a Reply

Your email address will not be published. Required fields are marked *