I have tried using the id, slug, name, and take the tax_query as an array of arrays but still it will output all the posts from that post type.
Here's my custom taxonomy, 'Event Specific':
function theme_event_category(){
$labels = array(
'name' => 'Event Specifics',
'singular_name'=> 'Specific',
'search_items' => 'Search Event Specifics',
'all_items' => 'All Event Specifics',
'parent_item' => 'Parent Event Specific',
'parent_item_colon' => 'Parent Colon:',
'edit_item' => 'Edit Specific Item',
'update_item' => 'Update Specific Item',
'add_new_item' => 'Add New Event Specific',
'new_item_name' => 'New Specific Item',
'menu_name' => 'Event Specific'
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'event')
);
register_taxonomy('event_specific', 'event', $args );
}
add_action('init', 'theme_event_category');
Here's my query, that should only output the 'Main Event' tag from the 'Event Specific' taxonomy:
$quertest = array(
'post_type' => 'event',
'posts_per_page' => 1,
'tax_query' => array(array('event_specific', 'slug', 'main-event')),
);
$upcoming_events = new WP_Query( $quertest );
<?php while ( $upcoming_events->have_posts() ) : $upcoming_events->the_post();
echo 'Title: ';
the_title();
?>