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:
<?php // Create a new instance $args = array( 'post_type' => 'course', 'tax_query' => array( 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?