Skip to content

Instantly share code, notes, and snippets.

@jamiejohnsonkc
Last active August 13, 2018 03:51
Show Gist options
  • Save jamiejohnsonkc/3940380e35b2cb4b3c0bc42115d43cc8 to your computer and use it in GitHub Desktop.
Save jamiejohnsonkc/3940380e35b2cb4b3c0bc42115d43cc8 to your computer and use it in GitHub Desktop.
Add Body Class, #php, #wordpress
add_filter( 'body_class', 'custom_class' );
function custom_class( $classes ) {
if ( is_page_template( 'page.php' ) ) {
$classes[] = 'doh';
}
return $classes;
}
<body <?php body_class( 'class-name' ); ?>>
The results would be:
<body class="page page-id-2 page-parent page-template-default logged-in class-name">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment