Created
May 2, 2020 13:58
-
-
Save dotherightthing/1abb8d54a0f6f8d0b8b51bfe97f381ae to your computer and use it in GitHub Desktop.
Add body class #wordpress #cheatsheet
This file contains hidden or 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 a class to the body | |
* | |
* @example | |
* add_filter( 'body_class', 'my_body_classes' ); | |
*/ | |
function my_body_classes( $classes ) { | |
// Adds a class of custom-background-image to sites with a custom background image. | |
if ( some_condition() ) { | |
$classes[] = 'custom-background-image'; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment