Last active
December 17, 2015 15:42
-
-
Save megmorsie/d3d07cc64e24373cea2a to your computer and use it in GitHub Desktop.
WordPress Stack Exchange: How to only show page id as body class?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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() */ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
View my posted answer.