WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a custom post type called 'course' which has 7 posts each being an individual training course.

I've also tagged them with individual custom taxonomies 'course_codes' eg. h001, h002, h003, etc. These correlate to the individual courses provided by a training centre.

I have several training centers that have there own custom post type 'training_centre' each training centre will be tagged with the same custom taxonomies 'course_codes' that they provide, not all training centres have the facilities to train all courses so some are only tagged with couple of courses.

So on my training centres template I've created a WP_Query to find all custom post type 'course' that have been tagged with the same custom taxonomy 'course_code' in training centres however, tax_query produces zero results, without tax_query I can get all the custom post types in 'course' however I only want the ones that are available at the training centre which is why I'm using 'course_code' to make the match - this is the code that produces zero results:

// Create a new instance
$args = array(
'post_type' => 'course',
'tax_query' => array(
        'taxonomy' => 'course_codes',
        'field' => 'slug',
        'term' => 'h001'
'post_status' => 'publish'

$welcomepost = new WP_Query($args);?>
<?php while( $welcomepost->have_posts() ) : $welcomepost->the_post();?>

    <?php the_title ();?>

<?php endwhile;?>
<?php wp_reset_postdata();?>

Where am I going wrong here, have I got the query wrong or am I going about this in the wrong way?

share|improve this question
up vote 1 down vote accepted

The term parameter should actually be terms, even when providing just one term:

$args = array( 'post_type' => 'course', 
               'tax_query' => array(     
                        'taxonomy' => 'course_codes',
                        'field' => 'slug',         
                        'terms' => 'h001'         
                 'post_status' => 'publish' 
share|improve this answer
Thank you, works a treat now, bit of a school boy error there! – erichmond Oct 2 '12 at 10:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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