Skip to content

Instantly share code, notes, and snippets.

@logoscreative
Created May 22, 2014 11:30
Show Gist options
  • Save logoscreative/c7d7374c1af58b6414e2 to your computer and use it in GitHub Desktop.
Save logoscreative/c7d7374c1af58b6414e2 to your computer and use it in GitHub Desktop.
Add a Class Conditionally for WordPress Page Templates
function prefix_conditional_body_class($classes) {
if ( get_page_template_slug(get_the_ID()) === 'mytemplate.php' ) {
$classes[] = 'bg-dark';
}
return $classes;
}
add_filter( 'body_class', 'prefix_conditional_body_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment