wp-bootstrap-navwalker icon indicating copy to clipboard operation
wp-bootstrap-navwalker copied to clipboard

Current Page parent with 3 levels.

Open ghost opened this issue 11 years ago • 4 comments

Hi there. I am sure this is simple, but I need a class that is only applied to the top level pages. The menu system is setup a bit differently on my site. Basically 3 levels.

Heres the CSS:

header nav ul > li.active > a,

header nav ul > li.current-page-parent > a {

background: rgba(28,147,205,.5)

Menu Item #1 -- Sub Menu One ---Third Level Item #1 ---Third Level Item #2 -- Sub Menu Two

If i select a third level item, it highlights its parent, but not the top level navigation parent. I have tried this with > and without. Is there a way to add a class specifically to just top level parents that contain an active child? With the design I have in place, the send level item shouldn't highlight unless it is the current page.

ghost avatar Jun 25 '15 19:06 ghost

WordPress's default parent hierarchy classes are applied, you simple need to add them to your css code.

SideQuestDIY avatar Jun 26 '15 22:06 SideQuestDIY

Could you tell me specifically what the class name is? Because i don't see any unique to top level class names.

These are what I see: menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-110 dropdown

I had to use JS for the time being to add an active class if the third level down item was listed as active.

ghost avatar Jun 26 '15 22:06 ghost

As referenced in issues #81

There is an active class applied to the parent but it is not its not called active walker outputs the standard WordPress classnames. You should style current-post-parent. This is makes it extremely simple if you are using LESS to compile your CSS as you can actually reference a class name and its properties inside another class.

.current-post-parent > a {
     .navbar-nav > .active > a;
}

.current-post-parent > a:hover {
     .navbar-nav > .active > a:hover;
}

When you compile this it should automatically apply the bootstrap active styles to the .current-post-parent class.

SideQuestDIY avatar Jul 20 '15 00:07 SideQuestDIY

.current-menu-parent a { color: #d7b22e !important; }

julien-sibille avatar Nov 17 '17 08:11 julien-sibille