Prepairing a function of similar posts faced the problem with wp_query. My args:
$args = array(
'post_type' => 'post',
'post__not_in' => array(pll_get_post($post->ID,'ru'),pll_get_post($post->ID,'uk')),
'posts_per_page' => $count,
'caller_get_posts' => 1,
);
if (!empty($position_array) || !empty($cities_array) || !empty($ages_array)) {
$args['tax_query'] = array(
'relation' => 'OR',
array(
'taxonomy' => 'position',
'field' => 'slug',
'terms' => $position_array,
),
array(
'taxonomy' => 'city',
'field' => 'slug',
'terms' => $cities_array,
),
array(
'taxonomy' => 'age',
'field' => 'slug',
'terms' => $ages_array,
),
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => $tag_array
)
);
};
print_r($args);
$my_query = new wp_query($args);
So it looks for posts similar by one of three custom taxonomies or tags, but must bypass current post in different languages (Polylang plugin).
If current language is default ('ru') function works good, but if i change language to 'uk', this function gives me similar posts and one of them is current post.
'post__not_in' => array(pll_get_post($post->ID,'ru'),pll_get_post($post->ID,'uk')),
- this returns proper ids (e.g. Array ( [0] => 331 [1] => 451 ) ). Why wp_query doesn't bypass current post in different languages?