Created
February 16, 2019 13:25
-
-
Save adamlaki/4acaa602b2b59a92510fcb8abff95041 to your computer and use it in GitHub Desktop.
Add Page Slug to Body Class in WordPress
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
<?php | |
function pine_add_page_slug_body_class( $classes ) { | |
global $post; | |
if ( isset( $post ) ) { | |
$classes[] = 'page-' . $post->post_name; | |
} | |
return $classes; | |
} | |
add_filter( 'body_class', 'pine_add_page_slug_body_class' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment