[Resolved] Disable sticky header navigation while scrolliong on blog posts

Home Forums Support Disable sticky header navigation while scrolliong on blog posts

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1293310
    Stephen

    Hello GeneratePress team,

    Currently struggling to disable sticky nav on my blog posts but retain it on rest of website.
    I’ve attempted to use this CSS to no avail:

    .single .navigation-stick,
    .single #sticky-placeholder {
    display: none !important;
    }

    Please let me know what I can use to get it to work if possible!

    Thanks in advance.

    #1293365
    David
    Staff
    Customer Support

    Hi there,

    you can use this Filter to disable the navigation:

    https://docs.generatepress.com/article/option_generate_menu_plus_settings/

    For example:

    add_filter( 'option_generate_menu_plus_settings','db_posts_disable_sticky_nav' );
    function db_posts_disable_sticky_nav( $options ) {
        if ( is_single() && 'post' == get_post_type() ) {
            $options['sticky_menu'] = 'false';
        }
        
        return $options;
    }

    https://docs.generatepress.com/article/adding-php/

    #1293391
    Stephen

    Sorry I’ve completely reworded my question. My fault entirely. In fact, I actually meant the complete opposite of what I have written haha!

    My stick nav currently hides itself when scrolling down. I need it to stay sticky when scrolling up and down but only on blog posts. Apologies for wording everything wrong!

    Thank you.

    #1293415
    David
    Staff
    Customer Support

    Same code applies just change the options 🙂

    So in the code above replace:

    $options['sticky_menu'] = 'false';

    with:

    $options['auto_hide_sticky'] = 'false';

    #1293421
    Stephen

    Ok, so I’ve used the following in code snippets and I’m afraid it still isn’t working:

    add_filter( ‘option_generate_menu_plus_settings’,’db_posts_disable_sticky_nav’ );
    function db_posts_disable_sticky_nav( $options ) {
    if ( is_single() && ‘post’ == get_post_type() ) {
    $options[‘auto_hide_sticky’] = ‘false’;
    }

    return $options;
    }

    Presumably I need to change ‘db_posts_disable_sticky_nav’ to something else but I’m not sure what, sorry!

    Thank you for your patience David

    #1293435
    David
    Staff
    Customer Support

    Thats odd. Try this.

    1. In Customizer > Layout > Sticky Navigation –> Uncheck the hide when scrolling down

    2. The add this Snippet:

    add_filter( 'option_generate_menu_plus_settings','db_posts_disable_sticky_hide' );
    function db_posts_disable_sticky_hide( $options ) {
    	
    	if ( !is_single() ) {
    		$options['auto_hide_sticky'] = 'true';
    	}
            
        return $options;
    } 

    This should now enable that feature whenever you’re NOT on a single post.

    #1293449
    Stephen

    Great, that has almost solved it. Only other thing is the nav bar now slides in on blog posts but I would like it to just stay in place. Is there a way I can do that too?

    Please see example – https://www.cleardesign.studio/boost-your-social-media-following/

    Thanks again

    #1293492
    David
    Staff
    Customer Support

    In Customizer > Layout > Sticky Navigation change the Transition to None

    #1293502
    Stephen

    Spot on, thats solved it thanks so much David.

    #1293510
    David
    Staff
    Customer Support

    Try disabling autoptimize and any other cache plugins as i can still see the slide effect enabled on the site.

    #1293512
    Stephen

    Sorry, I was mistaken with previous comment. All sorted now thank you

    #1293530
    David
    Staff
    Customer Support
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.