Archived topic
Primary menu item highlighted condition
7 replies · Started by Matthew on March 4, 2021
Under Appearance > Menus I have my home page entered in the URL field for a Custom Link menu item in my Primary menu.
This causes the navigation label to appear highlighted when on the site home page (home page displays my latest posts).
Once a link to a post on the home page is clicked and the single post page visited, the navigation label does not continue to appear highlighted. Can it be or should it be.
thanks,
Hi there,
WP adds a the current-menu-item tag whenever a link matches the current URL - so this is expected behaviour. Do you want to remove that styling when on the Home Page ?
No I want to keep that styling on the home page. I also want to see if it can be added for any single post page as well i.e. once clicked through from home to a blog page (currently current-menu-item is not being enforced there)
(currently current-menu-item is not being enforced there)
That doesn't sound right.
Can you link us to the page in question?
Hi Leo pls refer to private info box
Try adding this CSS:
.single-pictures .main-navigation .main-nav ul li.menu-item-home > a {
color: #ffffff;
background-color: #283747;
}
Thanks David it works well.
If I want to add my regular posts as well, can I add CSS to the same? I tried this but it doesn't work:
.single-pictures .single-post .main-navigation .main-nav ul li.menu-item-home > a {
color: #ffffff;
background-color: #283747;
}
Hi there,
You'll have to do something like this:
.single-pictures .main-navigation .main-nav ul li.menu-item-home > a, .single-post .main-navigation .main-nav ul li.menu-item-home > a {
color: #ffffff;
background-color: #283747;
}