Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

stack of vertical buttons for the side navigation

  • 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!

  • 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');
    
  • 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-5

    Because 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!

  • 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.

  • πŸ™‚πŸ™

    works like a charm πŸ‘

    Thank you very much!

  • You’re welcome

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.