Hi @greenbull
You’ll need to use filters for this.
Documentation: https://github.com/JoryHogeveen/off-canvas-sidebars/wiki/Actions-&-Filters
Specifically the ocs_is_sidebar_enabled
is useful in this case.
Cheers, Jory
Thank you for your answer.
I try many times but I have error each time.
add_filter( ‘ocs_is_sidebar_enabled’, false);
add_filter( ‘ocs_is_sidebar_enabled’, ‘__return_false’);
add_filter( ‘ocs_is_sidebar_enabled’, false, ‘ocs-filtres’ );
add_filter( ‘ocs_is_sidebar_enabled’, false, ‘filtres’ );
add_filter( ‘ocs_is_sidebar_enabled’, false, ‘ocs-filtres’, null );
Nothing working 😫
Ok sorry!
add_filter( ‘ocs_is_sidebar_enabled’, ‘__return_false’ );
working great! Thanks for your help 🙂
Glad to help!
If you want and have the time, please give the plugin a nice review to help it grow!
Cheers, Jory
I have added this snippet to my functions.php file to only load the off canvas sidebar on a specific post type. But the 2 javascript files and 2 css files still load on pages that do not have the sidebar. How can i prevent these assets from loading on pages that do not have the off canvas sidebar? Any guidance will be greatly appreciated. Thanks!
add_action( 'init', 'mirc_load_sidebars_for_guides' );
function mirc_load_sidebars_for_guides() {
if ( get_post_type() != 'guides' ) {
add_filter( 'ocs_is_sidebar_enabled', '__return_false' );
}
}