Skip to content

Instantly share code, notes, and snippets.

@acarabott
Created January 14, 2013 16:18
Show Gist options
  • Save acarabott/4531195 to your computer and use it in GitHub Desktop.
Save acarabott/4531195 to your computer and use it in GitHub Desktop.
Add page-slug to body class of wordpress pages
<?php
// Add to functions.php
// Add page-slug to body
function add_body_class( $classes )
{
global $post;
if ( isset( $post ) ) {
if (substr($post->post_type, 0, 4) == 'page') {
$classes[] = $post->post_type . '-' . $post->post_name;
}
}
return $classes;
}
add_filter( 'body_class', 'add_body_class' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment