Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - Please check what query generated based on the arguments you passed to Query:
SELECT wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND (
wp_term_relationships.term_taxonomy_id IN (25,27,36)
AND
wp_posts.ID NOT IN (
SELECT object_id
FROM wp_term_relationships
WHERE term_taxonomy_id IN (25,27)
)
) AND wp_posts.post_type = 'carte-item' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC
As you can see the argument is connected using "AND" clause and it says term_taxonomy_id IN (25,27,36) and term_taxonomy_id IN (25,27) - so I think this is the cause of the issue as when I change the argument to "OR":
For example - 'relation' =>'OR':
$args = array(
'posts_per_page' => -1,
'post_type' => $post_type,
'tax_query' => array(
'relation' =>'OR',
array(
'taxonomy' => $target_taxonomy,
'field' => 'term_id',
'operator' => 'IN',
'terms' => $current_term->term_id,
),
array(
'taxonomy' => $target_taxonomy,
'field' => 'term_id',
'operator' => 'NOT IN',
'terms' => $children_term_ids,
)
)
);
$the_query = new WP_Query($args);
It outputs the content - it breaks output when you have "AND" in your argument, actually this is not Toolset issue as all but the custom query you wrote. For your any custom programming need, I suggest you to contact our certified partners:
=> https://toolset.com/contractors/