Disable / enable on specific pages (including disabling JS and CSS files)
-
Hi Jory,
I’ve attempted setting up a function to disable the OCS on various pages. The code I came up with is:
function disable_off_canvas_sidebar_on_non_shop_pages() { if ( function_exists( 'is_woocommerce' ) && ! ( is_shop() || is_product_category() || is_product_tag() && ! ( in_array( 'garden-store', explode( '/', get_page_uri() ) ) ) ) ) { add_filter( 'ocs_is_sidebar_enabled', '__return_false' ); wp_dequeue_script( 'slidebars' ); wp_dequeue_script( 'off-canvas-sidebars' ); wp_dequeue_script( 'ocs-fixed-scrolltop' ); wp_dequeue_script( 'fastclick' ); wp_dequeue_style( 'off-canvas-sidebars' ); wp_dequeue_style( 'slidebars' ); } } add_action( 'wp_enqueue_scripts', 'disable_off_canvas_sidebar_on_non_shop_pages' );
This is successfully preventing the sidebar HTML from loading, but the OCS related JS and CSS is still loading. I also tried disabling with with
remove_action
in case theaction
function is what you used for loading it, but got the same result (no change).I’ve tried numerous other approaches to the code, but it seems I’m unable to prevent the JS and CSS loading.
I’m obviously overlooking something.
What would you suggest?
Thank you,
Jonathan
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Disable / enable on specific pages (including disabling JS and CSS files)’ is closed to new replies.