This thread is resolved. Here is a description of the problem and solution.
Problem:
You are using a WP Query to retrieve posts in a specific language, but the query returns posts in both languages despite the permalinks being correct.
Solution:
We recommend adding the
suppress_filters => false
parameter to your query. By default, the
get_posts()
function has
suppress_filters
set to true, which you need to explicitly override. Here's how you can modify your query:
$posts = get_posts(array( 'post_type' => 'post', 'posts_per_page' => 2, 'orderby' => 'date', 'order' => 'DESC', 'post__not_in' => array(get_the_ID()), 'suppress_filters' => false ));
This change should ensure that the query only returns posts from the selected language.
If this solution does not resolve your issue or 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 further assistance is needed, please do not hesitate to 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.