This thread is resolved. Here is a description of the problem and solution.
Problem:
The client is trying to retrieve all posts for a single language code using WP_Query and WPML filters, specifically for the default language code 'en'. The provided code with the
add_filter('wpml_query_filter', 'filter_wpml_query_for_english')
and the custom function did not work, as it still retrieved posts in all languages.
Solution:
We recommend using
'suppress_filters' => false
in the WP_Query arguments. This will ensure that the query retrieves posts in the current language when on the English version of the website. For further optimization, the client can specify the fields they want to retrieve, such as 'ID', 'post_title', and 'post_content'.
For more information on debugging theme compatibility with WPML, please visit: Debugging theme compatibility with WPML.
Additionally, for WPML hooks reference, check out: WPML hooks reference.
For WordPress reference on get_posts, please see: WordPress get_posts function.
If this solution doesn't look relevant, please open a new support ticket in our 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 1 reply, has 2 voices.
Last updated by 1 year, 5 months ago.
Assisted by: Andrey.