Skip to content

Instantly share code, notes, and snippets.

@ashfame
Created August 3, 2012 11:12
Show Gist options
  • Select an option

  • Save ashfame/3246712 to your computer and use it in GitHub Desktop.

Select an option

Save ashfame/3246712 to your computer and use it in GitHub Desktop.
Add page slug to body class
<?php
function custom_body_class($classes){
global $wp_query;
if ( is_page() ) {
$post_obj = $wp_query->get_queried_object();
array_push($classes, 'slug-'.$post_obj->post_name);
}
return $classes;
}
add_filter('body_class', 'custom_body_class');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment