Created
July 29, 2011 14:12
-
-
Save marcboivin/1113876 to your computer and use it in GitHub Desktop.
Add a class to your body, the simple way
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 | |
/* | |
WordPress now has a hook to add a body class. But it's kind of annoying | |
to deal with the add action and everything, so I made a little tiny wrapper | |
function that works only in php 5.3 + but still, makes my life easier when making | |
themes. | |
*/ | |
function add_class_body($class){ | |
add_filter('body_class', function($classes) use ($class){ | |
$classes[] = $class; | |
return $classes; | |
}, 100 ,1); | |
} | |
/* | |
Now you can just call add_body_class('myclass'); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment