I try to query custom post type called news
by a category called Alumni
with ID=160
.
When I use such arguments, as a result, I get all my custom posts without Alumni
category:
$args = array(
'posts_per_page' => -1,
'post_type' => 'news',
'orderby' => 'date',
'order' => 'DESC',
'category__not_in' => 160
);
$loop = new WP_Query( $args );
<?php while ( $loop->have_posts() ) : $loop->the_post();?>
...
<?php endwhile; ?>
However, changing category__not_in
to category__in
gives an empty list but I would expect the opposite of the initial result. I can't really understand where I make a mistake.
Also, I tried using cat
and category_name
instead and I played around with different categories but results were always the same.
In my research I came across 'tax_query'
but I can't get it to work as well. The documentation is not quite clear for me.