In my theme (Underscores based).

I have

<html <?php language_attributes(); ?>>

Then I'm calling the body class function on the body tag:

<body <?php body_class(); ?>>

Seeing as these body add a class="" I can't combine them by just appending the 2 functions.

Any way I can add a filter to language_attrubutes() so that it also appends the body class?

  • The body class belongs on the body, and language_attributes is for outputting the language attributes. Anything is is misusing these. What are you trying to achieve? It's not clear. It sounds like you want to use classes in the language attribute? What for? Commented Oct 12, 2018 at 0:36

1 Answer 1


Maybe you could use a filter to add the current language of the website to the body class.

add_filter('body_class', 'language_in_body_classes');
function language_in_body_classes($classes) {

    $classes[] = get_bloginfo('language');

    return $classes;

Edit : maybe I misunderstood what you wanted. There is actually a language_attributes filter but I do not think it would be very standard to add classes to the html language attr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.