Add class to wordpress body_class() function
I recently needed to add a unique class to the body class for various templates. I didn't want to write a function that cluttered the global namespace, so I wrote this function that uses create_function.
in your functions.php file add
function foo_add_body_class( $class_to_add = '' ) {
add_filter( 'body_class', create_function('$classes', 'return array_merge( $classes, array('.$class_to_add.') );' ) );
}
Then, in your template file all you need to do is add this one line of code before your get_heade() call.
foo_add_body_class( 'class-to-add' );
The function is limited to only one classname, but could be modified accept an array.