In a few installations of wordpress, the beginning of the html tag looks like

<html lang="en-US" ...

despite that in wp-config no language is specified.

define('WPLANG', '');

Hovever, in one installation the tag is

<html lang=" " ...

how would i change that to <html lang="en-us" ..., without changing the wp-config file

I'm talking about the front end, not the admin dashboard.

The code in header.php looks like this:

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

and the HTML render looks like this:

<!DOCTYPE html>
<html lang=" " prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#" class="no-js">
  • Are you talking about the admin pages or the front end? If the latter, look at your theme's header.php file (it might be called something similar) and paste the line with the opening <html ...> tag here.
    – mrwweb
    Aug 25, 2014 at 21:05
  • Is there a workaround without hard coding that?
    – idjuradj
    Aug 25, 2014 at 21:42
  • It depends on your answers to the questions I asked in the question above! Can't tell without understanding context (question 1) and seeing code (question 2).
    – mrwweb
    Aug 25, 2014 at 21:45
  • I updated my question.
    – idjuradj
    Aug 25, 2014 at 21:50
  • Thanks for the additional info. Are the sites without the language specified using a theme with a hard-coded language attribute? I don't see how you could get around not hard-coding it in one of wp-config.php or header.php.
    – mrwweb
    Aug 25, 2014 at 22:06

1 Answer 1


You can apply the language_attributes filter to language_attributes() function (source).

Basically you can do this by adding something like this to your functions.php:

add_filter('language_attributes', 'custom_lang_attr');
function custom_lang_attr() {
  return 'lang="en-US"';

Note: Keep in mind, that you're overwriting the language parameter; the original string (see @param) is a space-separated list of language attributes.

  • Thanks a lot @Sven. Can i somehow, in a similar manner, set a language for rss feed?
    – idjuradj
    Aug 26, 2014 at 0:03
  • @Nicholas It's probably a better idea to define <language> within the RSS feed. But that's a new question ;)
    – Sven
    Aug 26, 2014 at 0:25
  • 1
    New question it is then :)
    – idjuradj
    Aug 26, 2014 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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