Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active March 19, 2018 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddalton/f012dced06ffe71aac6c633bc0fa7750 to your computer and use it in GitHub Desktop.
Save braddalton/f012dced06ffe71aac6c633bc0fa7750 to your computer and use it in GitHub Desktop.
Add Custom Body Class Based on Slug https://wp.me/p1lTu0-hp5
add_filter( 'body_class', 'slug_body_class' );
function slug_body_class( $classes ) {
$body_class = 'custom-body-class';
$ternary = strpos($_SERVER['REQUEST_URI'], 'test-slug' ) ? $body_class : '';
$classes[] = $ternary;
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment