Last active
June 20, 2019 09:24
-
-
Save frankschrijvers/d58ccec56064bc41a4b57a13ee03f71f to your computer and use it in GitHub Desktop.
Add Page Slug as Body Class
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 shown above. Copy the code shown below. | |
add_filter( 'body_class', 'wps_add_slug_body_class' ); | |
/** | |
* Add Page Slug as Body Class. | |
*/ | |
function wps_add_slug_body_class( $classes ) { | |
global $post; | |
if ( isset( $post ) ) { | |
$classes[] = $post->post_type . '-' . $post->post_name; | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment