Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
I translate the page and save the translation, but when I go to a page for that language i.e. http://example.com/en/about-us/ the content of the header is still the default.

Solution:
First of all, please go to WPML → Settings → Custom XML Configuration tab and add this XML config to it:

<wpml-config>
    <admin-texts>
        <key name="indutri_theme_options">
            <key name="header_layout"/></key>
    </admin-texts>
</wpml-config>

Once you did this, please edit the header template:
https://website.com/wp-admin/post.php?post=16&action=edit&lang=en

Now, use the top admin language switcher and select Spanish:
https://website.com/wp-admin/post.php?post=22&action=edit&lang=es

Here, edit the Permalink and change fmt-header to fmt-header-es (just simply add -es at the end, so the permalink in each language can be different).

The last step is to go to WPML → String Translation and search for the header template permalink. In the test website is fmt-header. As the translation, just simply add the permalink that you just set, fmt-header-es.

This time, when checking a page in the secondary language, the translated header will be used:
https://website.com/es/

Relevant Documentation:
https://wpml.org/documentation/getting-started-guide/string-translation/finding-strings-that-dont-appear-on-the-string-translation-page/#strings-arent-selected-for-translation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 11 replies, has 2 voices.

Last updated by lukeG-7 3 years, 10 months ago.

Assisted by: Radu.

Author Posts
July 14, 2021 at 2:35 am #9191109

lukeG-7

Hi There,

I Cannot translate content of the header in my theme, I am using the Indutri theme which comes with a header and footer builder, I need to be able to change the HTML block on the menu to have a different button but none of the changes I make are working.

I translate the page and save the translation, but when I go to a page for that language i.e. hidden link the content of the header is still the default.

I have the site setup with English Australia as default, and English US is secondary.

I have also checked this translation in the strings section and the translation is there.

This site is not currently live so you cannot view because of IP restriction.

WPML Header Issue.jpg
July 14, 2021 at 4:02 am #9191427

lukeG-7

It looks like the WPML is translating the header to the /en/ URL, but that isn't what is being loaded on the page..

header.png
July 14, 2021 at 6:07 am #9191749

lukeG-7

I may have found a work around using a custom WPML string shortcode, but if theres anything I'm missing to make the menu switch properly please let me know.

July 14, 2021 at 7:57 am #9192327

Radu

Hey Luke,

Thank you for reaching out to the WPML support!

I am not familiar with the Industri theme and with the header builder, so it's hard to say why is this not working well. Also, the Industri theme is not a part of the WPML compatible themes list (https://wpml.org/theme) so there might be some compatibility issues here and there, like the header builder used by the theme.

I can have a look at it (if you could give me access to the dashboard area) but I can't guarantee that I'll be able to make it work with WPML. However, if you found a workaround for this one, it's better to keep using it this way.

Last but not least, if you do need to be able to translate the header elements, you can try t reach out to the theme authors and ask them to check the builder and make it work with WPML. If they need any help with this, they can always apply for the Go Global program (https://wpml.org/documentation/support/go-global-program/) where our compatibility team is waiting to work together with any author and make sure that WPML is working flawlessly with their theme or plugin.

Thanks,
Radu

July 15, 2021 at 12:12 am #9199489

lukeG-7

Hi Radu,

Unfortunately I can't give you access to the site because its behind IP restrictions, what I can do if it would be of any help is send you a copy of the theme files if this is something you are able to test?

If not, I might contact the theme developer and let them know, and just use the custom WPML string shortcode for the moment.

Also with the custom string shortcode, is there any option to say "If translation available, otherwise fallback to default language"?

July 15, 2021 at 1:54 am #9200041

lukeG-7

Sorry, the custom shortcode already defaults to default language for non-translated, please disregard that question.

July 15, 2021 at 10:23 am #9203047

Radu

Hey Luke,

Can you have a look at my previous message here, please?
https://wpml.org/forums/topic/cant-translate-content-of-header/#post-9203045

Thanks,
Radu

July 16, 2021 at 6:17 am #9214135

lukeG-7

Hi Radu,

I've had a chat with our developers and this is not something we are comfortable doing for a minor issue, the solution with the shortcode is working well.

I would be happy to send you the theme files if you would like to take a look but otherwise I might stick with the workaround at this stage.

July 16, 2021 at 1:12 pm #9217283

Radu

Hey Luke,

I'm sorry but even if I would have a look at the theme files, I won't be able to find out what's going on.
The last thing that I can do is to create a clean website:
hidden link

You can quickly configure WPML, install the theme, create the same header, and translate it. This way I'll be able to have a look at it and see if I can find any other way to make the HTML block on the translation work.

Thanks,
Radu

July 18, 2021 at 11:48 pm #9225895

lukeG-7

Hi Radu,

No worries, I was actually offering to provide the theme files if you were able to test locally but this works too.

I Have uploaded the theme and WPML, the header is set in Theme settings > Header Options.

You can edit the header in the Header Builder option in the WordPress menu.

By default the Header Builder is added as a non-translatable field. I've enabled this in Post-Types Translations and added a translation.

The spanish page shows the english header
hidden link

But here you can see the header is indeed being translated, just not loaded into the website pages.

hidden link

July 20, 2021 at 12:44 pm #9236793

Radu

Hey Luke,

Thank you for taking care of configuring the website so I can check the issue. I could see that the theme that you're using is saving the header option by using the header post slug (which is not a very practical way of saving the option).

First of all, please go to WPML → Settings → Custom XML Configuration tab and add this XML config to it:

<wpml-config>
    <admin-texts>
        <key name="indutri_theme_options">
            <key name="header_layout"/></key>
    </admin-texts>
</wpml-config>

Once you did this, please edit the header template - in the sandbox, is this one:
hidden link

Now, use the top admin language switcher and select Spanish:
hidden link

Here, edit the Permalink and change fmt-header to fmt-header-es (just simply add -es at the end, so the permalink in each language can be different).

The last step is to go to WPML → String Translation and search for the header template permalink. In the sandbox is fmt-header. As the translation, just simply add the permalink that you just set, fmt-header-es.

This time, when checking a page in the secondary language, the translated header will be used:
hidden link

Please give this a try on your website and tell me how it goes.

Thanks,
Radu

July 22, 2021 at 4:21 am #9249423

lukeG-7

That's great, thank you for your help with this 🙂