Skip to content

Instantly share code, notes, and snippets.

@megmorsie
Last active December 17, 2015 15:42
Show Gist options
  • Save megmorsie/d3d07cc64e24373cea2a to your computer and use it in GitHub Desktop.
Save megmorsie/d3d07cc64e24373cea2a to your computer and use it in GitHub Desktop.
WordPress Stack Exchange: How to only show page id as body class?
<?php
/*
* Plugin Name: Stack: How to only show page id as body class?
* Plugin URI: http://wordpress.stackexchange.com/questions/211556/how-to-only-show-page-id-as-body-class
* Description: Stack Exchange - WordPress Development
* Version: 1.0
* Author: Megan Morsie
* Author URI: http://megabyterose.com/
* License: GPL2
*/
/* START - Filter the body_class() */
// Apply filter
add_filter('body_class', 'wpse211556_body_classes');
function wpse211556_body_classes($classes) {
unset($classes);
$slug = strtolower(str_replace(' ', '-', trim(get_bloginfo('name'))));
$classes[] = $slug;
return $classes;
}
/* END - Filter the body_class() */
?>
@megmorsie
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment