This thread is resolved. Here is a description of the problem and solution.
Problem:
You are trying to use a product tag as a display rule in GeneratePress, but WPML is not replacing the product tag ID from the default language to the translated language product tag ID during translation. This issue occurs because WPML is copying _generate_element_display_conditions 1:1 without replacing the product tag ID.
Solution:
To resolve this issue, you need to modify the GeneratePress conditions file to include a WPML filter that correctly translates the product tag ID. Here are the steps:
1. Open the
app/public/wp-content/plugins/gp-premium/elements/class-conditions.php
file.
2. Locate the
Show depending on location conditionals
section around line 327.
3. Replace the existing code with the following snippet to include a WPML workaround:
// Show depending on location conditionals.<br />if ( ! $show ) {<br />foreach ( (array) $conditionals as $conditional ) {<br />// WPML Workaround for compsupp-7507<br />if ( class_exists('Sitepress') ) {<br /><br />$post_type = get_post_type( $conditional['object'] );<br />$term = get_term( $conditional['object'] );<br /><br />if ( $conditional['rule'] == 'product:taxonomy:product_tag' && $term && ! is_wp_error( $term ) ) {<br />$conditional['object'] = apply_filters( 'wpml_object_id', $conditional['object'], $term->taxonomy, TRUE );<br />}<br />else if ( $post_type ) {<br />$conditional['object'] = apply_filters( 'wpml_object_id', $conditional['object'], $post_type, TRUE );<br />} else if ( $term && ! is_wp_error( $term ) ) {<br />$conditional['object'] = apply_filters( 'wpml_object_id', $conditional['object'], $term->taxonomy, TRUE );<br />}<br />}<br />
This modification should ensure that WPML correctly translates the product tag ID in _generate_element_display_conditions.
If this solution does not apply to your case, or if it seems outdated, 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. If you still need assistance, please open a new support ticket 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 6 replies, has 2 voices.
Last updated by 7 months, 1 week ago.
Assisted by: Osama Mersal.