• Skip to main content
  • Skip to primary sidebar

WordPress, Genesis Framework and Storefront customization tutorials

  • Free
  • Premium
  • Membership
    • Login
  • Design
  • Blog
  • About
  • Contact
Home » Add page slug to body_class

Add page slug to body_class

2019-11-19 by Gabor Leave a Comment

// =========================================================================
// ADD PAGE SLUG TO BODY CLASS
// =========================================================================
function add_slug_to_body_class( $classes ) {
    global $post;
    if ( isset( $post ) ) {
        $classes[] = $post->post_name;
    }
    return $classes;
}
add_filter( 'body_class', 'add_slug_to_body_class' );

Filed Under: Free Tagged With: PHP

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube
WP Rocket - WordPress Caching Plugin
UpdraftPlus Premium

Disclosure: Some of the links in this site are affiliate links. I will be paid a commission if you use this link to make a purchase.

  • Privacy Policy
  • Terms of Service
  • Flames Design
© 2021 WP Flames - All Right Reserved