Your problem is that you didn’t wrap it in a callback, but executed it immediately when functions.php
was loaded by core. By then the global $wp_query
object isn’t initialized fully and the is_category()
etc. wrappers can’t deliver what you are expecting them to do. So your if/else checks should be moved inside the callback like this:
add_filter( 'body_class', 'addBodyClasses' );
function addBodyClasses( $classes )
{
if (
is_category()
|| is_tag()
|| is_home()
)
{
$classes = array_merge( $classes, array(
'hentry',
// other classes you want to add go here
) );
}
return $classes;
}