-
-
Save lmartins/0f499f3041dd3cdbfb45 to your computer and use it in GitHub Desktop.
Conditionally add classes to the body tag
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 | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sp_body_class' ); | |
function sp_body_class( $classes ) { | |
if ( is_category( '1' ) ) | |
$classes[] = 'custom-class'; | |
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
<?php | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sp_body_class' ); | |
function sp_body_class( $classes ) { | |
if ( is_category( 'sample-category' ) ) | |
$classes[] = 'custom-class'; | |
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
<?php | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sp_body_class' ); | |
function sp_body_class( $classes ) { | |
$classes[] = 'custom-class'; | |
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
<?php | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sp_body_class' ); | |
function sp_body_class( $classes ) { | |
if ( is_page( '1' ) ) | |
$classes[] = 'custom-class'; | |
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
<?php | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sp_body_class' ); | |
function sp_body_class( $classes ) { | |
if ( is_page( 'sample-page' ) ) | |
$classes[] = 'custom-class'; | |
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
<?php | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sp_body_class' ); | |
function sp_body_class( $classes ) { | |
if ( is_tag( '1' ) ) | |
$classes[] = 'custom-class'; | |
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
<?php | |
//* Do NOT include the opening php tag | |
//* Add custom body class to the head | |
add_filter( 'body_class', 'sp_body_class' ); | |
function sp_body_class( $classes ) { | |
if ( is_tag( 'sample-tag' ) ) | |
$classes[] = 'custom-class'; | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment