WPML: wp_query() returns posts in all languages rather than just current one

drake035 picture drake035 · Mar 4, 2015 · Viewed 10.1k times · Source

No matter whether I use it from my page in French version or in English version, wp_query() returns my custom post types in all languages, not just in the current one. Get_posts() does the same thing too.

When I visit my page in French, I want them to return CPTs in the current language only. How to achieve that?

Answer

P-S picture P-S · Mar 7, 2015

When using get_posts(), set suppress_filters to false:

$myPosts = get_posts(array(
    'suppress_filters' => false
));

http://codex.wordpress.org/Function_Reference/get_posts#Parameters