Last active
June 28, 2018 19:27
-
-
Save samkent/7a3bfe1ea207652a98dc to your computer and use it in GitHub Desktop.
WordPress add body class if page template
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
<?php | |
/** | |
* Add a custom body class for a specific page template | |
* Add the following to your theme functions.php file. | |
*/ | |
add_filter( 'body_class', 'custom_class' ); | |
function custom_class( $classes ) { | |
if ( is_page_template( 'templates/page-contact.php' ) ) { | |
$classes[] = 'contact'; | |
} | |
return $classes; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment