Site logo

Archived topic

Secondary Navigation > color of active item > RegEx pattern possible?

6 replies · Started by Christian on September 22, 2021

Viewing posts 1–7 of 7

Dear GeneratePress Support Team,

my website uses the secondary navigation for a members area. The members area has a menu item like: https://website.tld/my-profile/username-a (the username is changing depending on the user, like: username-b, username-c and so on).
The template /my-profile/ is the menu item in the secondary nav - and I want it to change backgroundcolor, when the profile page is active.
However, it does not change color since the active page has the pattern */my-profile/username-a.
Now my question: is it possible to set the colorchange in this particular menu item to follow some RegEx pattern like:
always change color to active if pattern is:
#/my-profile/#
?
Thank you for your consideration,
Best,
Chris

Hi there,

its should be possible with the menu item classes that WP adds.
Would you be able to share a link to a profile page ?

Thank you David,

yes, this is possible, however the second navigation is restricted to logged in users. I've added admin credentials in the private information area below.

Thanks, Chris

You could try this CSS:

.uwp_profile_page .secondary-navigation .main-nav > ul > li.users-wp-profile-nav a {
    background-color: #f00;
}

The uwp_profile_page is a body class for that template.
And the users-wp-profile-nav item is present on that menu item.

So it should only style that top level menu item when you're on the profile page

David,
this works perfectly. Just added the font color to the CSS and everything is perfect.
Thank you so much!

I mark this topic as resolved.

As I often state: Generatepress (and Generateblocks) rocks!

Chris

Awesome - glad to be of help!

This archived topic is closed to new replies.