Skip to content

Instantly share code, notes, and snippets.

@robertstaddon
Last active June 14, 2023 18:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertstaddon/73d7e74d9b69b228116d000bda61d764 to your computer and use it in GitHub Desktop.
Save robertstaddon/73d7e74d9b69b228116d000bda61d764 to your computer and use it in GitHub Desktop.
Divi - remove Divi sidebar from all WooCommerce Product pages (as well as Shop and Category pages) pages with a hook
<?php
/**
* Remove Divi sidebar from all WooCommerce Product pages (as well as Shop and Category pages)
*/
function mytheme_divi_output_content_wrapper_end() {
echo '
</div> <!-- #left-area -->
</div> <!-- #content-area -->
</div> <!-- .container -->
</div> <!-- #main-content -->';
}
function mytheme_remove_divi_sidebar() {
remove_action( 'woocommerce_after_main_content', 'et_divi_output_content_wrapper_end', 10 );
add_action( 'woocommerce_after_main_content', 'mytheme_divi_output_content_wrapper_end', 10 );
}
add_action( 'init', 'mytheme_remove_divi_sidebar', 10 );
/**
* Adjust the WooCommerce body classes for all WooCommerce Product pages (as well as Shop and Category pages)
*/
function mytheme_body_classes( $classes ) {
if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
$remove_classes = array('et_right_sidebar', 'et_left_sidebar', 'et_includes_sidebar');
foreach( $classes as $key => $value ) {
if ( in_array( $value, $remove_classes ) ) unset( $classes[$key] );
}
$classes[] = 'et_full_width_page';
}
return $classes;
}
add_filter('body_class', 'mytheme_body_classes', 20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment