Skip to content

Instantly share code, notes, and snippets.

@cjkoepke
Last active August 29, 2015 14:26
Show Gist options
  • Save cjkoepke/c439025a5286d91e1553 to your computer and use it in GitHub Desktop.
Save cjkoepke/c439025a5286d91e1553 to your computer and use it in GitHub Desktop.
Apply multiple custom classes to the body tag with the body_class filter.
<?php
//* Do NOT include the opening php tag
add_filter( 'body_class', 'ck_custom_body_classes' );
function ck_custom_body_classes( $classes ) {
//* Create an empty value (or add a default to be applied everywhere)
$classes[] = "";
if ( is_front_page() ) {
$classes[] = "front-page";
}
if ( is_page_template( 'page_blog.php' ) ) {
$classes[] = "blog-page";
}
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment