I'm trying to exclude the items within a custom taxonomy category (slug: private-case-study, ID: 5) from a loop. I'm using the following code, does anyone have suggestions or ideas why it's not working? Thanks in advance!
// Get the current page ID
$this_post = $post->ID;
$private_case_study = get_term_by('slug', 'private-case-study', 'mgt_portfolio_filter');
// Show items from specific category
if($category_name == '') {
$wp_query = new WP_Query(array(
'post_type' => 'mgt_portfolio',
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'order' => $order,
'post__not_in' => array($this_post, $private_case_study)
));
} else {
$wp_query = new WP_Query(array(
'post_type' => 'mgt_portfolio',
'tax_query' => array(
array(
'taxonomy' => 'mgt_portfolio_filter',
'field' => 'slug',
'terms' => $category_name,
),
),
'posts_per_page' => $posts_per_page,
'orderby' => $orderby,
'post__not_in' => array($this_post, $private_case_study),
'order' => $order
));
}