Last active
September 6, 2021 15:12
-
-
Save nathaningram/d80c1968a85ea344c613cf4e32cc5053 to your computer and use it in GitHub Desktop.
Add Post Slug as Body Class
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 Page Slug to Body Class | |
| function ni_add_slug_body_class( $classes ) { | |
| global $post; | |
| if ( isset( $post ) ) { | |
| $classes[] = $post->post_type . '-' . $post->post_name; | |
| } | |
| return $classes; } | |
| add_filter( 'body_class', 'ni_add_slug_body_class' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment