Black Friday sale! Get up to 25% off GP Premium! Learn more ➝

[Support request] WPML – Page Header – Global locations

Home Forums Support [Support request] WPML – Page Header – Global locations

Home Forums Support WPML – Page Header – Global locations

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #375199

    The page headers can be translated with WPML.
    But unfortunately one cannot assign the page headers according to the Language in >Global Locations.

    Example : There are several languages and the page headers are in these languages. But for single pages and posts one can only assign a page header in one language.
    When creating a post in a different language than that of the assigned page header, one has to select the translated page header manually.
    This is no problem as long as one is Admin.
    But it is an issue for the role of authors, whom I don’t want grant access to the page header widget. (Otherwise an author can select wrong page headers or miss this feature)
    It should happen automatically, that a post in Language A get page header A, a post in Language B gets page header B, etc, etc.

    What is missing on the Global Location page is a function & checkbox, whether the translated page headers should be used in translated pages & posts.

    Lead Developer
    Lead Developer

    Hmm, that’s a tough problem. Adding the ability to choose different headers/language in Global Locations would involve a considerable amount of code.

    I wonder if it would be better to apply WPML to the content of your Page Header? That way the Page Header stays the same, but the content within it can be translated.


    I don’t understand what you mean with applying WPML to the content?
    In the editor there is no function, where I can choose Language A and then content A, Language B and then content B, etc. (Actually a good idea … would be very practical and convenient)
    The only thing that can be done is translating whole custom posts, pages, etc.

    With WPML one also can translate the menus. The user adds another menu and declares it as a translation of Language A.
    Maybe it needs something like that in Global Locations, where the user can add another set of Global Locations as a translation of the initial language and then assign there the headers.

    I do imagine, that this is for sure complex and not an easy task. Yet, if GP wants to be a 100% WPML compatible, then this part with Global Locations needs to be considered, especially because because Global locations is a general setting for posts and pages.

    Lead Developer
    Lead Developer

    I don’t have tons of experience with WPML, but the Page Header content area is just a custom field, which I know are translatable:

    So you should be able to translate the content only.

    The name of the custom field you need to translate is: _meta-generate-page-header-content


    Hi Tom
    I was dealing with same problem for several days. Native language of my site is Spanish and English as second language.
    I’ve tried different approaches to get ‘Page headers’ for the blog page for each language using WPML plugin. In my case I am using Elementor to design the headers and insert them as shortcode in the content field.

    My first try was:
    1. I create a template in Elementor to be used as custom header in blog page.
    2. I make the translation to English for this template with WPML
    3. I create the Page Header called ‘Blog’ and insert the Elementor shortcode in ‘Content’ tab.
    4. In Page Headers > Global Locations I set up “Blog” in ‘Posts Page (blog)’ dropdown

    Result: Same Page header (Spanish) for both languages

    Second try (what you suggested):
    1. I create a template in Elementor to be used as custom header in blog page.
    2. I clone this template and edit it for for English
    3. I create two Page Headers, let’s say “Heading Blog for Spanish” and “Heading Blog for English”, then I insert the shortcode of each language created in 1 and 2 in each Page Header.
    4. I go to ‘Blog’ page (posts page in reading setup) I select ‘Heading Blog for Spanish’ and enable the translation for _meta-generate-page-header-content custom field to be translatable as well (as you suggested).
    5. Now, when I edit the fields to translate to English, I can see in _meta-generate-page-header-content custom field that you save the #ID of ‘Page Header’ CPT, therefore I put in the #ID of “Heading Blog for English”
    Worth mention I leave empty the ‘blog’ option in Global Locations since if I pick one, I’ll see in both languages.

    Result: None Page Headers is displayed when you select one in ‘blog’ page. (Is this a expect behavior?)

    Third try and solution.
    I searched for if there were conditional tags for WPML and I came across with this post
    So, steps were next:
    1. I create a template in Elementor to be used as custom header in posts page.
    2. I clone this template and edit it for for English
    3. I create one Page Headers, let’s say “Heading for Blog” and insert in content area a mixup of shortcodes: WPML conditionals and Elementor shortcodes:

    [wpml_language language="en"][elementor-template id="1670"][/wpml_language]
    [wpml_language language="es"][elementor-template id="1273"][/wpml_language]

    4. In Page Headers > Global Locations I set up “Heading for Blog” in ‘Posts Page (blog)’ dropdown.

    Result: I get different ‘Page Headers’ for each language in my posts page.

    I don’t have much idea programming but it works for me, so I hope this solution helps to someone else.
    Best regards

    Lead Developer
    Lead Developer

    Thank you so much for outlining what didn’t and did work for you. I’m sure it will help someone 🙂

    Martin U

    This was indeed extremely helpful.

    BTW you need to add this to the function PHP.

    // wpml shortcodes --------------------
    add_shortcode( 'wpml_language', 'wpml_find_language');
    /* ---------------------------------------------------------------------------
     * Shortcode [wpml_language language="en"] [/wpml_language]
     * --------------------------------------------------------------------------- */
    function wpml_find_language( $attr, $content = null ){
            'language' => '',
        ), $attr));
        $current_language = ICL_LANGUAGE_CODE;
        if($current_language == $language){
            $output = do_shortcode($content);
            $output = "";
        return $output;

    I tried to set the custom post type (Elements) as translatable, in hopes of being able to translate the custom field (_meta-generate-page-header-content), but it never showed up in WPML, so I couldn’t set it as translatable. I was only able to translate my custom header by using Fernando’s shortcode method (thanks!).

    Lead Developer
    Lead Developer

    The custom field for the Element field is: _generate_element_content

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.