Last active
August 13, 2018 03:51
-
-
Save jamiejohnsonkc/3940380e35b2cb4b3c0bc42115d43cc8 to your computer and use it in GitHub Desktop.
Add Body Class, #php, #wordpress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'body_class', 'custom_class' ); | |
function custom_class( $classes ) { | |
if ( is_page_template( 'page.php' ) ) { | |
$classes[] = 'doh'; | |
} | |
return $classes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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