Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Plugin Name: Slug to Body Class
Version: 0.1
Plugin URI:
Description: Add Page/Post Slug to Body Class
Author: Syed Balkhi
Author URI:
// From:
add_filter( 'body_class', 'add_slug_body_class' );
function 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
You can’t perform that action at this time.