I have a two custom post types "venues" and "events".. How do i query "venues" then display all the "events" that have the same taxonomy values.

$taxonomy = 'venue-name';
$param_type = 'venue-name';
$tags = wp_get_post_terms( $post->ID , $taxonomy, $tax_args);
if ($tags) {
foreach ($tags as $tag) {
  $args = array(
              'post_type' => 'venues',
              "$param_type" => $tag->slug,
              'post__not_in' => array($post->ID),
              'showposts'=> 1,    
  $my_query = new WP_Query($args);
  if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); 

1 Answer 1


Didn't test the following code but it should help you in the right direction.

$args = array(
    'post_type' => array('venues', 'events'),
    'post__not_in' => array($post->ID),
    'tax_query' => array(
            'taxonomy' => 'custom_taxonomy',
            'field'    => 'slug',
            'terms'    => $tags,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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