Archived topic
fixed navigation bar on product page in mobile view
9 replies · Started by José on May 6, 2019
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.
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.
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
I just adjusted the code in your post. Can you re-copy/paste it and let me know if it works?
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.
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
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;
}
Hey Leo, Thanks for your answer, I will leave it annotated ...
Regards
No problem :)