Skip Navigation

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

Problem:

The client is experiencing issues with translating Bricks Builder pages using WPML. The main symptoms include improper translations and CSS/JS rendering issues on the translated pages.

Solution:

1) Ensure a full site backup is performed.
2) Navigate to WPML>>Settings>>Post Types Translation and select *Translatable only show translated items* for My Templates (bricks_template) post type.
3) Save the changes.
4) Go to Bricks>>Templates>>My Templates and translate the Header & Footer templates.
5) Update the Homepage in the original language after a minor edit to refresh the translation settings.

Additionally, add the following code to the functions.php file of your theme:

add_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10, 4);
function wpml_compsupp7667_bricks_translate_template_conditions($value, $post_id, $key, $single) {
    if ($key !== '_bricks_template_settings') {
        return $value;
    }
  
    // Remove filter temporarily to avoid infinite loop
    remove_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10);
      
    // Get all meta values
    $raw_values = get_post_meta($post_id, $key, false);
      
    // Add filter back
    add_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10, 4);
  
    // If we have no values, return the original
    if (empty($raw_values)) {
        return $value;
    }
  
    // Process the array structure
    foreach ($raw_values as &$settings) {
        if (is_array($settings) && isset($settings['templateConditions'])) {
            foreach ($settings['templateConditions'] as &$condition) {
                if (!empty($condition['archiveTerms']) && is_array($condition['archiveTerms'])) {
                    foreach ($condition['archiveTerms'] as &$termString) {
                        if (strpos($termString, '::') !== false) {
                            list($taxonomy, $termId) = explode('::', $termString);
                            $translatedId = apply_filters('wpml_object_id', intval($termId), $taxonomy, true);
                            if ($translatedId) {
                                $termString = $taxonomy . '::' . $translatedId;
                            }
                        }
                    }
                }
            }
        }
    }
  
    return $raw_values;
}

For further details on this issue, please refer to the following errata: Bricks theme template conditions not applied correctly in translated templates.

If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. Please feel free to open a new support ticket for further assistance at WPML support forum.

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 5 replies, has 1 voice.

Last updated by Bigul 1 month, 3 weeks ago.

Assisted by: Bigul.

Author Posts
April 8, 2025 at 9:45 am #16908169
mirceaD

Or this page: hidden link

How can I get them to display properly and not have broken CSS?

New threads created by Bigul and linked to this one are listed below:

https://wpml.org/forums/topic/the-translated-pages-are-displaying-broken-or-incorrect-css-styles/

April 8, 2025 at 9:53 am #16908186

mirceaD

I followed your steps to translate the header and footer and now it's really broken, there is a clear problem with the css/js is rendered when your program translates and I want it fixed

April 8, 2025 at 2:25 pm #16910030

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the detailed feedback. Somehow, the translated templates are not working as expected in the secondary languages. It looks like a compatibility issue and is related to the following known issue.

https://wpml.org/errata/bricks-theme-template-conditions-not-applied-correctly-in-translated-templates/

So I made a copy of the site. I will debug it further and get back to you soon.

Also, I have created a new ticket for the style conflicts in the secondary languages pages. It will help us to avoid discussing multiple things in a single ticket.

--
Thanks!

Bigul

April 9, 2025 at 2:49 pm #16914548

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

I am getting the expected results in my local copy for the Header and Footer in English pages after the following steps.

1) Add the following code in functions.php (on the bottom of the file) of theme

add_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10, 4);
function wpml_compsupp7667_bricks_translate_template_conditions($value, $post_id, $key, $single) {
    if ($key !== '_bricks_template_settings') {
        return $value;
    }
 
    // Remove filter temporarily to avoid infinite loop
    remove_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10);
     
    // Get all meta values
    $raw_values = get_post_meta($post_id, $key, false);
     
    // Add filter back
    add_filter('get_post_metadata', 'wpml_compsupp7667_bricks_translate_template_conditions', 10, 4);
 
    // If we have no values, return the original
    if (empty($raw_values)) {
        return $value;
    }
 
    // Process the array structure
    foreach ($raw_values as &$settings) {
        if (is_array($settings) && isset($settings['templateConditions'])) {
            foreach ($settings['templateConditions'] as &$condition) {
                if (!empty($condition['archiveTerms']) && is_array($condition['archiveTerms'])) {
                    foreach ($condition['archiveTerms'] as &$termString) {
                        if (strpos($termString, '::') !== false) {
                            list($taxonomy, $termId) = explode('::', $termString);
                            $translatedId = apply_filters('wpml_object_id', intval($termId), $taxonomy, true);
                            if ($translatedId) {
                                $termString = $taxonomy . '::' . $translatedId;
                            }
                        }
                    }
                }
            }
        }
    }
 
    return $raw_values;
}

2) Save the changes in the file
3) Visit WPML>>Settings>>Post Types Translation
4) Choose *Translatable only show translated items* option for My Templates (bricks_template) post type
5) Save the changes
6) Visit Bricks>>Templates>>My Templates
7) Open the Header template for editing in Romanian language
8) Make a minor change to the contents (to refresh the translation settings) and save the changes
9) Update the English translation of the Header Template from WPML Translation Editor, and publish it
10) Followed the same steps (7 to 9) for Footer template

Please try it on your live site after a full site backup and let us know your feedback. Refer to the attached images and the following errata for more details

https://wpml.org/errata/bricks-theme-template-conditions-not-applied-correctly-in-translated-templates/

We have a request. Please complete the translation of the remaining template, the products, and the pages. It will help you get the expected results in English, like the primary language.

--
Thanks!

Bigul

2025-04-09_20h18_42.png
2025-04-09_20h14_03.png
2025-04-09_20h00_31.png
April 11, 2025 at 10:55 am #16922272

mirceaD

Hello, I followed your exact steps twice, but now my footer and header are completely gone when I switch to the secondary language.

Even tried adding to functions.php vs a snippets plugin.

April 11, 2025 at 4:27 pm #16923804

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Please check it now. The header and footer were missing on the English pages because the template was in the Trash and also set as a Draft.

So publishing it and updating the templates in Romanian and English helped to fix the issue.

--
Thanks!

Bigul

2025-04-11_21h54_07.png
April 17, 2025 at 4:19 pm #16945206
mirceaD

The cart page is not translated at all, I've translated the bricks template as well.

New threads created by Bigul and linked to this one are listed below:

https://wpml.org/forums/topic/the-cart-page-is-not-translated/

April 18, 2025 at 2:45 am #16946133

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

Thank you for the updates. I have added a new ticket for the Cart Page issue. We will get back to you on the latest ticket as early as possible. Please wait.

--
Thanks!

Bigul

April 22, 2025 at 11:57 am #16955081

mirceaD

Hello, any update on this?

April 22, 2025 at 2:09 pm #16955604

Bigul
WPML Supporter since 01/2013

Languages: English (English )

Timezone: Europe/Vienna (GMT+02:00)

Hello,

I hope you are checking about the Cart page issue. If so, please check the following ticket and let us know your feedback there.

https://wpml.org/forums/topic/the-cart-page-is-not-translated/

--
Thanks!

Bigul