Skip to content

Instantly share code, notes, and snippets.

@richtabor
Last active October 2, 2017 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richtabor/bffade63c4737ad0cc339fca63b0bc80 to your computer and use it in GitHub Desktop.
Save richtabor/bffade63c4737ad0cc339fca63b0bc80 to your computer and use it in GitHub Desktop.
<?php
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
function prefix_body_classes( $classes ) {
// Add class to the body if the sidebar has widgets.
if ( is_active_sidebar( 'sidebar-1' ) && ! is_page() ) {
$classes[] = 'has-sidebar';
}
return $classes;
}
add_filter( 'body_class', 'prefix_body_classes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment