I use Plugin Polylang. I need to display one post into 3 categories (one category, but for any language the plugin polylang needs to create 3 different categories), it's important to make this without duplicating the post for any category, because I need to make 1 common post(with common rating) for all langs. I tried in theme_folder/category.php before if ( have_posts() ) : set:

$categories = get_the_category();
        $category_id = $categories[0]->cat_ID;
        $posts = get_posts( array(
            'category' => pll_get_term($category_id, 'ro'),
            'post_type' => 'post',
        ) );

nothing changes... and:

$posts = get_posts( array(
            'category'=> $category_id,
            'post_type' => 'post',
            'lang' => 'ro',
        ) );

result: working correctly only if language is 'ro', if I change the language in site, then it displays only empty posts.



to retrieve all posts of all languages in a category, you need to desactivate the auto-translate during the request.
you can try that :

$categories = get_the_category();
$category_id = $categories[0]->cat_ID;

remove_filter( 'get_terms_args', array( PLL()->auto_translate, 'get_terms_args' ), 10, 2 );

$posts = [];

foreach (pll_languages_list() as $language_code) {

    $posts = array_merge(
            "category" => pll_get_term($category_id, $language_code),
            "post_type" => "post",
            "lang" => $language_code,


add_filter( 'get_terms_args', array( PLL()->auto_translate, 'get_terms_args' ), 10, 2 );

Not the answer you're looking for? Browse other questions tagged or ask your own question.