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: ';

1 Answer 1


In your tax_query array you need to add the keys as well as the values.


'tax_query' => array(
        'taxonomy' => 'event_specific', 
        'field' => 'slug', 
        'terms' => 'main-event'
  • you know what Mr. @Nath, i've tried that before and didn't work. but now i tried it again and it mysteriously worked! thanks :O
    – Smee
    May 19, 2016 at 5:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.