Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/*
Plugin Name: Slug to Body Class
Version: 0.1
Plugin URI: http://www.wpbeginner.com/wp-themes/how-to-add-page-slug-in-body-class-of-your-wordpress-themes/
Description: Add Page/Post Slug to Body Class
Author: Syed Balkhi
Author URI: https://plus.google.com/101623299936375408403/
*/
// From: http://www.wpbeginner.com/wp-themes/how-to-add-page-slug-in-body-class-of-your-wordpress-themes/
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.