Created
April 9, 2012 14:55
-
-
Save jeremyboggs/2344038 to your computer and use it in GitHub Desktop.
Adds post title as a value to WP's body_class and post_class
This file contains hidden or 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 | |
function add_post_title_class($classes) { | |
global $post; | |
if ($postTitle = sanitize_title($post->post_title)) { | |
$classes[] = $postTitle; | |
} | |
return $classes; | |
} | |
add_filter('body_class', 'add_post_title_class'); | |
add_filter('post_class', 'add_post_title_class'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment