[Resolved] fixed navigation bar on product page in mobile view

Home Forums Support [Resolved] fixed navigation bar on product page in mobile view

Home Forums Support fixed navigation bar on product page in mobile view

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #891315
    José

    Hi there, I have enabled sticky browsing on the desktop and mobile.
    I would like to leave the navigation bar fixed only on the product page in the mobile version … how can I do it?

    The attention is appreciated.

    #891463
    David
    Staff
    Customer Support

    Hi there,

    you can use the Menu Plus Options:

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

    Woocommerce uses the is_product() conditional tag for the single product page.

    #892260
    José

    Hi David, the plus menu does not respond to the mobile header (appearance / customize). enyway I added the following code to the son theme:

    add_filter( 'option_generate_menu_plus_settings', 'lh_custom_homepage_menu_plus_settings' );
    function lh_custom_homepage_menu_plus_settings( $options ) {
        if ( is_front_page() ) {
            $options['mobile_header_sticky'] = 'disable';
        }
        
        return $options;
    }

    …but the site breaks with the filter.

    What am I doing wrong?

    Thanks

    #892328
    Tom
    Lead Developer
    Lead Developer

    I just adjusted the code in your post. Can you re-copy/paste it and let me know if it works?

    #892373
    José

    Hi Tom, I added the code and it works fine, but it only works on the home page, on the product page it had no effect …

    The attention is appreciated.

    #892611
    David
    Staff
    Customer Support

    In this code change:

    is_front_page()

    to

    is_product()

    #893339
    José

    Hi David works perfect.
    Just to know, if I need to also configure the navigation in the home.
    To add is_front_page () and is_product () in the same filter code
    This is the correct way to do it?:

    add_filter( 'option_generate_menu_plus_settings', 'lh_custom_homepage_menu_plus_settings' );
    function lh_custom_homepage_menu_plus_settings( $options ) {
        if ( is_front_page() ) {
            $options['mobile_header_sticky'] = 'disable';
        }
        
        if ( is_product() ) {
            $options['mobile_header_sticky'] = 'disable';
        }
    
        return $options;
    }

    Thanks for your time

    #893385
    Leo
    Staff
    Customer Support

    You can combine them like this:

    add_filter( 'option_generate_menu_plus_settings', 'lh_custom_homepage_menu_plus_settings' );
    function lh_custom_homepage_menu_plus_settings( $options ) {
        if ( is_front_page() || is_product() ) {
            $options['mobile_header_sticky'] = 'disable';
        }
    
        return $options;
    }
    #893415
    José

    Hey Leo, Thanks for your answer, I will leave it annotated …

    Regards

    #893534
    Leo
    Staff
    Customer Support

    No problem 🙂

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