Archived topic
#generate-slideout-menu removal on some pages
5 replies · Started by johnaps on December 29, 2020
Hello i want the #generate-slideout-menu element to exist only some pages...
Can i enable it only on specific pages with a hook or something?
Because on pages like this https://sofianos-orthopedika.gr/%CE%B1%CE%BD%CE%B1%CF%80%CE%B7%CF%81%CE%B9%CE%BA%CE%AC-%CE%B1%CE%BC%CE%B1%CE%BE%CE%AF%CE%B4%CE%B9%CE%B1/%CE%B1%CE%BC%CE%B1%CE%BE%CE%AF%CE%B4%CE%B9%CE%B1-%CE%B5%CE%BD%CE%B7%CE%BB%CE%AF%CE%BA%CF%89%CE%BD/
it is html bloat basically it isnt being used...
Hi there,
you can use option_generate_menu_plus_setting filter to disable the slideout_menu this article explains:
https://docs.generatepress.com/article/option_generate_menu_plus_settings/
So would the following work for my case?
//disable #generate-slideout-menu everywhere
add_filter( 'option_generate_menu_plus_settings','lh_all_pages_menu_plus_settings' );
function lh_all_pages_menu_plus_settings( $options ) {
$options['slideout_menu'] = 'false';
return $options;
}
//enable #generate-slideout-menu only on product filter categories
add_filter( 'option_generate_menu_plus_settings','lh_custom_pages_menu_plus_settings' );
function lh_custom_pages_menu_plus_settings( $options ) {
if( is_product_category( array('category1-slug', 'category2-slug' )) ) {
$options['slideout_menu'] = 'mobile';
}
return $options;
}
If you disable the Off Canvas in the Customizer then you should only require the second PHP snippet ie .//enable #generate-slideout-menu only on product filter categories
i turned off, off canvas and added this to my functions.php
//enable #generate-slideout-menu only on product filter categories
add_filter( 'option_generate_menu_plus_settings','lh_custom_pages_menu_plus_settings' );
function lh_custom_pages_menu_plus_settings( $options ) {
if( is_product_category( array('νοσοκομειακα-κρεβατια', 'ηλεκτροκίνητα-αναπηρικά-αμαξίδια', 'χειροκίνητα-αναπηρικά-αμαξίδια', 'μαξιλάρια-ύπνου', '/οξυγονοθεραπεία/συμπυκνωτές-οξυγόνου-φιάλες/')) ) {
$options['slideout_menu'] = 'both';
}
return $options;
}
the button that opens the off canvas menu, that appears under 1050px doesnt work (https://ibb.co/0qhcnxB)
I believe you don't require the array for the is_product_category() eg.
is_product_category('category-slug1','category-slug2')