Created
July 16, 2019 19:56
-
-
Save samkent/15b76655828f544801ee680baacfb409 to your computer and use it in GitHub Desktop.
Add body class if WordPress 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 body class if WordPress page template | |
* @link https://developer.wordpress.org/reference/functions/body_class/ | |
*/ | |
add_filter( 'body_class', 'custom_class' ); | |
function custom_class( $classes ) { | |
if ( is_page_template( 'page-example.php' ) ) { | |
$classes[] = 'example'; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment