Divi - remove Divi sidebar from all WooCommerce Product pages (as well as Shop and Category pages) pages with a hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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