I didn’t find a suitable WordPress plugin for this, because they usually do much more and introduce a whole translation management solution. Including changing all URLs across the whole site.

So let’s KISS – keep it simple and stupid!

Yet another WordPress Plugin: «Language Locale Overwrite»

Why not publish this to the world – when I have already created and using it? 😎

There’s a somewhat comprehensive README in the repository

What does this WordPress Plugin do?

Changing the HTML lang attribute in WordPress

While tackling some search engine optimizations of this blog, I wanted to fix two things:

  1. First, «globally»: the blog should indicate a «neutral English» (en) language – instead of specifically «English (United States)» (en-US).
Screenshot of Language Overwrite for whole Site using my WordPress Plugin
  1. Second, «per Post(s)»: so that I can properly tag the correct language on some single posts, written in German in early days of this blog, with the language attribute «German» (de).
Screenshot of a Language Overwrite for single Posts Pages using my WordPress Plugin
  1. And last but not least, «Alternate Hreflang metatags»: easily allow selecting translated Posts / Pages, so that they are referenced properly using SEO alternate hreflang tags.
Screenshot of Language Overwrite showing Alternate Hreflang metatags to translated Posts

How can the Plugin be used?

As this is not an officially published Plugin on the WordPress Plugin directory, please follow the instructions as documented on the GitHub project:

Once installed and set-up, there’s a new section in the WordPress “Settings » General” to change global language settings, and within the Block Editor to change a Post’s/Page’s HTML lang attribute.

I hope this helps somebody who might have the same situation with multiple language posts in their WordPress blog.

Share:
  • 4
  • 2

4 thoughts on “Change HTML lang & add alternate hreflang links to WordPress blogs”

  1. Hi !

    Thanks for the share – your plugin is exactly what I needed !
    But … something’s wrong as I try to use it (version 2.0.0) :
    on the bottom of my pages, I see Language Locale section and i can choose language… but alternate link section looks like this, with the error message :

    Warning: array_unique() expects parameter 1 to be array, null given in /var/www/kamelecom.com/padel/wp-content/plugins/language-locale-overwrite-2.0.0/language-locale-overwrite.php on line 255

    Warning: Invalid argument supplied for foreach() in /var/www/kamelecom.com/padel/wp-content/plugins/language-locale-overwrite-2.0.0/language-locale-overwrite.php on line 164

    How to fix it to use it to also choose alternate links ?

    Thanks for help

  2. Hi, thanks for plugin! Its fantastic.

    I have site with native lng – en-US and I need add some ua pages….. So, I add ua page in section «Language Locale» set – uk_UA and for native EN page set – en-US… updated and this: “use the «Link alternate lang…»-dropdowns to make cross-links” – dropdowns not exist…. I slso try clear en-US for native lng page…. result same….. Where I’m wrong? Thanks

    1. Hi Dmytro,
      It‘s hard to tell why that’s not working for you. One thing: try adding en-UA (instead of uk-UA, as this seems not a valid language-Country code…).

      And make sure you use the newest version.

Questions? Suggestions? Let us know with a comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.