Support » Plugin: MultilingualPress » Hreflang defaults to regional language code

  • Resolved smorrisrosenstein


    Hi! I have just started using the plugin and am having problems with setting hreflang correctly.

    I have created international variants of the languages I need by overwriting unused languages in the list and with EN, IT, ES, and FR I haven’t had any problems, but when I create the Portuguese site it defaults to “pt-BR” instead of just “pt”. This is what the code looks like:

    <link rel="alternate" hreflang="en" href=""><link rel="alternate" hreflang="es" href=""><link rel="alternate" hreflang="it" href=""><link rel="alternate" hreflang="fr" href=""><strong><link rel="alternate" hreflang="pt-BR" href=""></strong><style type="text/css" media="print">#wpadminbar { display:none; }</style>

    This is how the languages are set up:

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Thorsten Frommen


    Hi there,

    seems like you did a good job in setting up your custom language variants.

    For Portuguese, I can only assume that you mistakenly chose the wong language, and not Portuguese (Int)…?

    Can you double-check?
    You can also have a look at the value in the <select> element in your browser’s developer tools or so.


    PS: One unrelated thing: why did you set all the languages to be RTL (right-to-left), when they’re clearly not? Did you maybe forget to uncheck that from the languages you customized?

    Thanks for the quick reply!

    I double checked and it wasn’t a mistake in language selection. I actually deleted and re-created the new page a couple of times to test this and the error persisted. I’ll see if the error repeats with other languages and get back to you if it does.

    In the meantime, I’ve found a (somewhat hacky) solution: I changed the regional variants “pt-PT” and “pt-BR” to “pt”. We’re not planning on doing regional targeting so losing these two variants is not a problem for now, and I can always restore to default if needed.

    On RTL, you’re correct. I ticked all the new languages to mark them and forgot to undo it.

    Plugin Contributor Thorsten Frommen


    Hm, good that you found a workaround. But still, this is strange.
    Could you export the languages table, wp_mlp_languages (there shouldn’t be any sensible data in there) and send the DB dump (of that table) to, or upload it somewhere and provide a link here? Also, could you paste what’s inside the site languages option (see code)?

    SELECT meta_value FROM wp_sitemeta WHERE meta_key = 'inpsyde_multilingual';

    Please adapt yout table prefix, wp_, if necessary.

    Thanks in advance!


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hreflang defaults to regional language code’ is closed to new replies.