Search code examples
wordpresswpml

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


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?


Solution

  • 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