Skip to content

Instantly share code, notes, and snippets.

@itsdavidmorgan
Last active November 19, 2018 16:48
Show Gist options
  • Save itsdavidmorgan/b81bc25b520c236a5b597e4e83c630e2 to your computer and use it in GitHub Desktop.
Save itsdavidmorgan/b81bc25b520c236a5b597e4e83c630e2 to your computer and use it in GitHub Desktop.
WordPress Body Class That Conditionally Displays If Sidebar Is Present
function organic_origin_body_class( $classes ) {
if ( is_active_sidebar( 'sidebar-1' ) && ! is_page_template( 'template-full.php' ) && ! class_exists( 'Woocommerce' ) || is_active_sidebar( 'sidebar-1' ) && ! is_page_template( 'template-full.php' ) && ( class_exists( 'Woocommerce' ) && ! is_woocommerce() ) || class_exists( 'Woocommerce' ) && is_woocommerce() && is_active_sidebar( 'shop-sidebar' ) ) {
$classes[] = 'origin-sidebar-active';
} else {
$classes[] = 'origin-sidebar-inactive';
}
}
add_action( 'body_class', 'organic_origin_body_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment