I've been banging my head against the wall for last couple of days trying to exclude a category from an archive of easy digital downloads, which i am displaying in a custom widget, however i cannot hide a category called 'custom-project' no matter what i try.
This is the code i am trying to use, based on instructions from https://codex.wordpress.org/Class_Reference/WP_Query
$argsQuery = array(
'posts_per_page' => 3,
'post_type' => 'download',
'tax_query' => array(
array(
'taxonomy' => 'download_category',
'field' => 'slug',
'terms' => 'custom-project',
'include_children' => true,
'operator' => 'NOT_IN'
)
),
);
$get_latest_downloads = new WP_Query( $argsQuery );
$i=1;
while ( $get_latest_downloads->have_posts() ) : $get_latest_downloads->the_post();
//WIDGET BODY CODE
$i++;
endwhile;
I also tried using 'cat' instead of 'tax_query', but with no success as the category 'custom-project' is still displaying inside the loop of posts.
$argsQuery = array(
'posts_per_page' => 3,
'post_type' => 'download',
'cat' => '-5',
);
$get_latest_downloads = new WP_Query( $argsQuery );
$i=1;
while ( $get_latest_downloads->have_posts() ) : $get_latest_downloads->the_post();
//WIDGET BODY CODE
$i++;
endwhile;
I am certain that slug name and category ID are correct. Any kind of help is greatly appreciated.