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;
}
Related Posts:
- How to move parent li to end of child ul
- How to insert custom code into wp_nav_menu structure?
- Grey out nav buttons unless is_user_logged_in()
- Static page to one page- menu inactive items highlighted
- How Do I Add Images To Main Navigation Menu
- display menu as table layout
- Menu Arrow for Child Element
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- How to add css to single navigation text? [closed]
- Odd spacing in Navigation Bar [closed]
- wp_nav_menu container style args
- Add/remove image from navigation bar
- Additional CSS for the nav menu
- Disable Top Nav Bar on Mobile
- Active page link not getting class assigned
- individual images as navigation design TwentyTen
- How to add or remove borders in navigation menu?
- Site navigation sits unstyled for a second on page reload [closed]
- Is there an easy way to replace a custom menu link with a page or post?
- Add Javascript to WordPress Menu
- Use navigation path from menu for permalink
- Show only 2nd level of navigation depending on active navigation
- How to get a different mobile menu than desktop menu in the twentytwelve child theme
- HTML Bootstrap navigation menu to WordPress menu using wp_nav_menu
- WordPress Export Import Site Navigation Menu
- Bar separated navigation by extending Walker_Nav_Menu
- Replace menu tag with tag
- How to style current page menu item when using a walker
- Adding different classes to anchor in navigation menu
- How to change Twenty Seventeen theme’s navigation bar location?
- Second nav is merged with the first in mobile
- WordPress – site with 2 stylesheets and more…
- Add nav menu CSS class to body
- How to display dynamic content in start_lvl function
- Using Shortcodes in WP-Menus in WP 3.1 (via nav_menu_objects)?
- Disable automatig SVG tag from menu
- wp_nav_menu add some element to container
- Auto add pages to primary menu with functions.php
- Find out if a page has no parent
- how to remove the top navigation bar or header top on wordpress website?
- Add class active to static menu
- Can’t include Language switch in Nav Menu
- how can i add css class on current page in wordpress wp_nav_menu
- How to rewrite the output of wordpress nav menu?
- How to dynamically populate a dropdown
- wp_nav_menu not working [closed]
- I want to hide the navigation menu on a particular page
- automatically append menu parent as first item in submenu with nav_walker
- CSS Classes (optional) on menu is not showing
- Help with walker for nav
- My Temptation theme is showing two of the same menu at the top. How do I remove the one that the theme comes with? Please help! [closed]
- Hide menu from homepage
- WordPress + Bootstrap [closed]
- Adding toggle-able element after menu item
- Navigation menu not visible (contrast issue) on home page
- Full screen nav menu block with avada theme
- Add custom link on the fly to nav menu
- Custom register_taxonomy ins’t showing custom Nav menu
- Conditional menus based on page title
- How to test if a specific page is the front page?
- Style wp_link_pages as a select drop down list
- How to add columns to wordpress menu editor
- how to insert data in li tag of navigation
- Mobile navigation is shown, but standard navigation does not disappear
- Output Post ID for all nav_items
- changing the labels inside appearance -> menus for some for the fields
- Controlling sub-menu within sub-menu
- Styling issue with custom menus and sub menus
- WP Menu Rollover Nav Item and Effect DIV Elsewhere
- How to change the navigation menu
- How to add CSS class to and and id in a nav menu with code?
- WordPress nav_menu items from another menu appearing
- How can I order these pages in this navigation bar on this old wordpress theme?
- How to create a mobile menu full screen overlay using Understraps Bootstrap 4 theme
- Where to place a svg chevron down in my custom walker?
- Add href to tag in nav menu for mobile
- Output existing wp_nav_menu with a custom walker
- Sub-Items Not Visible in Navigation
- Adding span to a particular text in an menu item
- How can I create this menu with wp_nav_menu()?
- Unable to remove page from primary menu
- Show navigation header menu by post and categery
- How to Use Default Auto-Generated Menu?
- wp-nav menu with custom walker , how to remove a tag if it has any submenu
- Custom location for menu
- Adding two same css class on menu item
- Two questions about CSSing inside the menus
- Always show wordpress submenu on responsive header menu
- Can’t style custom menu
- Determine if a navigation item has children
- wordpress superfish dropdown menu
- Unable to edit Navigation bar
- Menu Underline shows without Hover after adding subitems
- Site pages show the page title under navigation bar
- Keeping my Sub Menu open when hovering on its list items
- Navigation menu, remove item from desktop
- Wrapping my ‘s with
- how to add permalink/slug to wordpress custom link menu item
- How to add a class directly on a unordered list element that is a primary navigation
- How do I programatically remove Menus?