OnPoint Plugins

  • Plugins
    • Advanced Sidebar Menu
      • Basic Version
        • Documenation
        • Usage
        • Developer Docs
      • PRO Version
        • Demo
        • Usage
        • Developer Docs
    • Go Live Update Urls
      • Basic Version
        • Documenation
        • Usage
        • Troubleshooting
      • PRO Version
        • Demo
        • Usage
        • URL History
  • About
    • Services
    • Showcase
  • Blog
  • Contact
  • Support
  • Log In
← Back to support

Need “current” classes up navigation tree

Resolved

Requested: 2 years and 3 months ago

Hi, I have a menu with 3 or 4 levels.  I see there is a “current-menu-parent” class that gets added to the current menu parent, but I also need classes that go all the way up to the top level items, for example “current-menu-grandparent” and “current-menu-greatgrandparent” or even just a simple class all the way through that shows as “current-menu”.  How can I get this sort of class or classes to show?

Plugin: Advanced Sidebar Menu

  1. Avatar for OnPoint PluginsOnPoint Plugins

    2 years and 3 months ago

    Hi Mary,

    It sounds like the class you are looking for is “current-menu-ancestor”. This class will be available on every level of the menu above the current item.

    If you are not seeing this class, please let us know and provide a link to where we can see the menu.

    Have a great day!

  2. Avatar for Mary WalshMary Walsh

    2 years and 3 months ago

    I believe so, but no I don’t see this class.  I’m expecting to see this on the “News” top level item on this page:

  3. Avatar for OnPoint PluginsOnPoint Plugins

    2 years and 3 months ago

    Hi Mary,

    I was able to track the issue down. This is what is happening:

    1. The current post is not part of the menu.
    2. The “News Releases” menu item happens to be a category the current post is assigned to.
      1. WP core gives the current parent classes to assigned categories.
    3. The “News” menu item is a custom link which does not have any relation to posts nor categories.

    Because the current post is not part of the menu, WP does not assign ancestor classes to any menu items.

    You may add the following filter to your active theme’s functions.php file to include the “current-menu-ancestor” class on parent/grandparent menu items which meet this criteria:

    1. Category menu items (and possibly other similar types).
      1. If current post is assigned to this category.
    2. When the current post is not in the menu.

    Have a great day!

     

New Response Cancel reply

You must be logged in to respond. Only PRO members are allowed to respond to support requests.

© 2025 · WordPress Development · Terms Of Service · Privacy Policy · Cookie Policy · Log in

  • Plugins
  • Blog
  • Contact