Home › Forums › Support › Highlighting parent menu item of a child page when child page is not in menu
- This topic has 10 replies, 4 voices, and was last updated 3 years, 11 months ago by
Tom.
-
AuthorPosts
-
March 16, 2019 at 6:50 am #840699
Ethan
Hello!
I have a parent page that has a number of child pages. All of the child pages are are set to that parent page. However, the parent page menu item is only highlighted when the child page is also included in the menu. I want the parent page menu item to be highlighted when a user is on the child page, even though the child page isn’t also in the menu.
The site is still in development so I will submit the login info via the form.
Once you can see the site, a specific example is this:
– Parent page is “Resources.”
– Two examples of child pages are “Vocabulary” and “Schools.” Both of these are set to have “Resources” as the parent page (links available on Resources page).
– I added “Vocabulary” page to the menu, under “Resources” just to try it out, and when on “Vocabulary” page, the parent page menu item is correctly highlighted (as expected).
– “Schools” child page is not in the menu, and the parent page menu item does NOT highlight when viewing the “Schools” page – but I want the parent menu item (Resources) to be highlighted when on this (and other) child page that is not included in the menu.GeneratePress 2.2.2GP Premium 1.7.8March 16, 2019 at 7:28 am #840734David
StaffCustomer SupportHi there,
could you provide a link to the site. You can edit your original topic and use the Site URL field for privacy.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 16, 2019 at 1:20 pm #840960Ethan
The site is not live yet. I submitted log in information in an Account Issue contact form so you can log in to see it.
March 16, 2019 at 6:57 pm #841089Tom
Lead DeveloperLead DeveloperHi there,
Give this CSS a shot:
.main-navigation .main-nav .current-page-ancestor > a { color: #f2c100; background-color: #3f075e; }
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 17, 2019 at 4:31 pm #841719Ethan
Thanks, Tom – yes, that works and now the parent menu item is highlighted when on the child pages, even when the child pages aren’t in the menu. Thank you!
However, when I am on a child page that is NOT in the menu, the parent menu item hover color is applied when you hover over the parent menu item. This is different from when you are on a child page that IS in the menu, which does NOT show the parent menu item hover color when you hover over the parent item.
The lack of applying the hover color to the parent menu item when you are on a child page seems to be standard fare (examples on the site under “Membership/Donate”), and it used to bother me – but I’ve gotten used to it. So I guess it does’t matter which way it is, but can you help me make it at least standard across the site?
So either: when on a child page (regardless of if the child page is included in the menu), show the hover color on the parent menu item OR don’t show the hover color on the parent menu item.
March 17, 2019 at 5:13 pm #841739Tom
Lead DeveloperLead DeveloperAh, give this a shot instead:
.main-navigation .main-nav .current-page-ancestor > a, .main-navigation .main-nav .current-page-ancestor.sfHover > a, .main-navigation .main-nav .current-page-ancestor:hover > a { color: #f2c100; background-color: #3f075e; }
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 17, 2019 at 6:30 pm #841758Ethan
Genius! Thank you!
March 18, 2019 at 8:42 am #842319Tom
Lead DeveloperLead DeveloperYou’re welcome π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 3, 2019 at 5:58 pm #888422Alexandre
Hi,
I’m trying to apply this code to my situation. It works but not completely. The menu label gets the same color as the background.
.elementor-nav-menu--main .elementor-nav-menu .current-page-ancestor > a, .elementor-nav-menu--main .elementor-nav-menu .current-page-ancestor.sfHover > a, .elementor-nav-menu--main .elementor-nav-menu .current-page-ancestor:hover > a { color:#ffffff; background-color: #b21b16; }
https://alexgauvin.com/cotefleury/produits/serrurerie/
Thanks for your support
May 3, 2019 at 6:38 pm #888437Alexandre
OK,
I found it.
#menu-1-a19b848 .current-page-ancestor > a { color:#ffffff; background-color: #b21b16; }
Simply replace
menu-1-a19b848
with own menu IDThanks
May 4, 2019 at 7:36 am #888932Tom
Lead DeveloperLead DeveloperGlad you got it working – thanks for sharing your code π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.