Skip Navigation

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 1 reply, has 2 voices.

Last updated by Prosenjit Barman 1 year, 4 months ago.

Author Posts
January 18, 2024 at 7:25 am #15198188

sachaC-4

I am set site in my local
hidden link
i have two language like EN and AR
when i am on AR page its also return EN products

Query is as below
$filter_products = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => $posts_per_page,
'paged' => 1,
'orderby' => 'date',
'suppress_filters' => false,
'meta_query' => array(
"relation" => "AND",
array(
'key' => '_price',
'value' => ($range_min_value) ? $range_min_value : "0",
'compare' => '>=',
'type' => 'NUMERIC'
),
array(
'key' => '_price',
'value' => ($range_max_value) ? $range_max_value : "1000",
'compare' => '<=',
'type' => 'NUMERIC'
)
)
);

$filter_productsPost = new WP_Query($filter_products);

I done know why there is "OR condition" for en language in sql see below

SELECT SQL_CALC_FOUND_ROWS yswp_gstic_posts.id
FROM yswp_gstic_posts
INNER JOIN yswp_gstic_postmeta
ON ( yswp_gstic_posts.id = yswp_gstic_postmeta.post_id )
INNER JOIN yswp_gstic_postmeta AS mt1
ON ( yswp_gstic_posts.id = mt1.post_id )
JOIN yswp_gstic_icl_translations wpml_translations
ON yswp_gstic_posts.id = wpml_translations.element_id
AND wpml_translations.element_type = Concat('post_',
yswp_gstic_posts.post_type)
WHERE 1 = 1
AND ( ( yswp_gstic_postmeta.meta_key = '_price'
AND Cast(yswp_gstic_postmeta.meta_value AS signed) >= '0' )
AND ( mt1.meta_key = '_price'
AND Cast(mt1.meta_value AS signed) <= '50000' ) )
AND yswp_gstic_posts.post_type = 'product'
AND (( yswp_gstic_posts.post_status = 'publish' ))
AND ( ( ( wpml_translations.language_code = 'ar' OR ( wpml_translations.language_code = 'en'
AND yswp_gstic_posts.post_type IN ( 'product' )
AND ( ( (SELECT Count(element_id)
FROM yswp_gstic_icl_translations
WHERE trid = wpml_translations.trid
AND language_code = 'ar') = 0 )
OR ( (SELECT Count(element_id)
FROM yswp_gstic_icl_translations t2
JOIN yswp_gstic_posts p
ON p.id = t2.element_id
WHERE t2.trid = wpml_translations.trid
AND t2.language_code = 'ar'
AND ( p.post_status = 'publish'
OR p.post_status = 'private'
OR (
p.post_type = 'attachment'
AND p.post_status = 'inherit' )
)) =
0
)
)
) )
AND yswp_gstic_posts.post_type IN (
'post', 'page', 'attachment', 'wp_block',
'wp_template',
'wp_template_part',
'wp_navigation'
, 'product',
'product_variation',
'wpcf7_contact_form'
) )
OR yswp_gstic_posts.post_type NOT IN (
'post', 'page', 'attachment', 'wp_block',
'wp_template',
'wp_template_part',
'wp_navigation'
, 'product',
'product_variation',
'wpcf7_contact_form' ) )
GROUP BY yswp_gstic_posts.id
ORDER BY yswp_gstic_posts.post_date DESC
LIMIT 0, 9

January 18, 2024 at 9:15 am #15198783

Prosenjit Barman
WPML Supporter since 03/2023

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There.
Thank you for reaching out to WPML Support.

Based on your description, I understand that the English products are being displayed on the Arabic page. From the WPML Debug Info, I can see that the translation preference for the Product post type is set to "Translatable - use translation if available or fallback to default language". This adjustment ensures that if translation is not available for a specific product, it will then fall back to the default language, which in your case seems to be English.

Before this matter is assigned to my colleague for a detailed follow-up, I would recommend a preliminary step that might address the issue. Please navigate to your WordPress dashboard and follow these steps:

- Go to WPML > Settings.
- Scroll down to the 'Post Type Translation' section.
- Locate the 'Product' post type.
- Change the translation preference for the Product post type to "Translatable
only show translated items".

Please apply this change and check if it resolves the issue. If you need further assistance, please let us know and we will be glad to help.

Best regards,
Prosenjit