-
Stefanie
Hi team,
on this page (link in private field) I want to use a stack of vertical buttons for the side navigation (instead of WP navigation)
The font-weight changes on :hover from 400 to 700. That works.
I would now like the font-weight to remain at 700 when the page is the current page.
Do you have an idea on how I can achieve this?
Thanks for a hint!
-
David
Hi there,
try this PHP Snippet:
function add_custom_button_styles() { global $wp; $current_url_slug = home_url(add_query_arg(array(), $wp->request)); $current_slug = str_replace(home_url('/'), '', $current_url_slug); printf( '<style> .gb-button[href*="%s"] { font-weight: 700 !important; } </style>', esc_attr($current_slug) ); } add_action('wp_head', 'add_custom_button_styles');
-
Stefanie
Thank you very much, David, that works almost fine
There is one problem left: on this page (in private field) two menu items are now displayed in 700.
This is probably because they have a very similar permalink.
permalink 1: zen-meditation-practice
permalink 2: zen-meditation-practice-5Because the site ranks well on google, I don’t want to change the permalink.
Is there a way to hit the [href] of the link exactly?I’ve tried this, but strangely this doesn’t work:
.gb-button[href="%s"]
Thank you very much!
-
David
Hmmm…. try this PHP Snippet instead:
function add_custom_button_styles() { global $wp; $current_url_slug = home_url(add_query_arg(array(), $wp->request)); printf( '<style> .gb-button[href="%s"] { font-weight: 700 !important; } </style>', esc_attr($current_url_slug) ); } add_action('wp_head', 'add_custom_button_styles');
It goes for an exact URL match.
-
Stefanie
🙂🙏
works like a charm 👍
Thank you very much!
-
David
You’re welcome
- You must be logged in to reply to this topic.