Swiss-Mac-User / language-locale-overwrite

This lightweight SEO plugin for WordPress allows overwriting the HTML lang attribute, including on individual Posts and Pages. And adds easy-to-use Alternate Hreflang tags.
https://swissmacuser.ch/wordpress-html-lang-locale-overwrite-plugin/
MIT License
8 stars 1 forks source link
accessibility internationalization multilanguage-support seo-optimization wordpress wordpress-plugin

Language Locale Overwrite for WordPress

This lightweight SEO plugin for WordPress allows changing the default HTML lang attribute globally, and on individual Posts and Pages. Along with cross-referencing similar Posts/Pages in different Languages using Alternate Hreflang tags.

The Plugin is mostly of use when your WordPress blog contains a mix of languages with individual Posts/Pages, and you do not want to install a huge translation plugin (because your posts are not actually translations, but just each individually published in a different content language). Accordingly you may also not want to change any of the URLs of your existing articles.

šŸ’” What does this do?

  1. Allows changing the default HTML lang attribute for your Blog,
  2. overwriting the HTML lang attribute on individual Posts and Pages (in addition to 1.),
  3. and cross-referencing Posts/Pages in different languages using Alternate Hreflang tags.

I developed this because my Blog is mostly written in English, but contains some articels written in German - of which some have gotten a content recycle across the two languages. And I wanted to improve their respective search engine optimization. In addition, with this plugin, I was able to change the default "English (United States)" (en-US) language code to just neutral "English" (en).

šŸŽ“ How to use

āš™ļø Install and enable the Plugin

šŸ“ Settings

Global change of <html lang="ā€¦">

  1. Go to your WordPress "Settings Ā» General" at /wp-admin/options-general.php#llo_global
  2. Set your desired ISO-Language/-Country locale using the setting Ā«Change HTML lang attributeĀ»
  3. (Optional) For OpenGraph og:locale you can set a preferred 2-char country code using Ā«Custom Country codeĀ»

Individual HTML lang change for Posts/Pages

  1. Open any Post or Page, for which you want to modify its language locale
  2. There's a new section Ā«Language LocaleĀ» where a valid ISO-Language/-Country code can be specified

Link Posts/Pages with same content in different languages

Pre-requisite: you must have Post/Pages already tagged with a "non-default" language locale!

  1. Edit the Post or Page, for which you want to reference a translated Post/Page
  2. In the Ā«Language LocaleĀ» section, use the Ā«Link alternate langā€¦Ā»-dropdowns to make cross-links

ā„¹ļø List of valid language locales

Valid language locales either consist of 2-characters ISO-code for languages, or a combination thereof with a 2-characters ISO country code. Here are some examples:


Support this project with a Coffee.