Skip Navigation

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

Problem: I need to change the query language

Solution: You can change the language before executing the query by adding these lines:

global $sitepress; $lang='fr'; $sitepress->switch_lang($lang);

Then add the query you need.

This will allow your query to get posts from 'fr' .

Relevant Documentation:

  • Find more information on WP_query and how it is used in WordPress.

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 4 replies, has 2 voices.

Last updated by arronG 5 years, 8 months ago.

Assigned support staff: Mohammed.

Author Posts
January 25, 2016 at 10:27 pm #796072


I am trying to use the WP_query class to call for posts that are in a different language of the one that I am currently in. I am in Fr and I call

$args = array(
	"post_type" => "post",
	"post_status" => "publish",
	"posts_per_page" => "1",
	"suppress_filters" => false,
	"name" => $slug,
	"orderby" => "date",
	"order" => "DESC"
$query = new WP_Query($args);

where $slug is a post slug.

I want to ALWAYS search in english no matter what the current language is.

I then can use the API to grab the french side of things if my business logic commands it but due to the nature of the project the slug request will always occur in english. and I always want that query to return english results.


January 26, 2016 at 5:01 pm #796843


Hello Arron,

Thank you for contacting WPML support.

You can change the language before executing the mentioned query by adding this line:

global $sitepress;

This will allow your query to get posts from 'fr' .

I hope this works with you.


January 26, 2016 at 6:32 pm #796960


And then I just switch back after right?

January 26, 2016 at 6:37 pm #796968


Hi Arron,

Yes exactly.

January 26, 2016 at 9:51 pm #797121


Thank you sir. for future reference where is this in your docs?