Here’s what I’m testing with:
<?php
$args = array(
‘post_type’ => ‘classes_camps’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘class_type’,
‘field’ => ‘slug’,
‘terms’ => array(‘first-stage’),
‘operator’ => ‘IN’
)
),
‘posts_per_page’ => -1
);
$query = new WP_Query($args);
while($query -> have_posts() ) : $query -> the_post();
?>
<h1><?php the_title(); ?></h1>
<?php endwhile; wp_reset_query(); ?>
What I ultimately need to do:
<?php
$args = array(
‘post_type’ => ‘classes_camps’,
‘tax_query’ => array(
‘relation’ => ‘AND’,
array(
‘taxonomy’ => ‘class_term’,
‘field’ => ‘slug’,
‘terms’ => array(‘2018-summer’),
‘operator’ => ‘IN’
),
array(
‘taxonomy’ => ‘class_type’,
‘field’ => ‘slug’,
‘terms’ => array(‘skills’),
‘operator’ => ‘IN’
),
array(
‘taxonomy’ => ‘session’,
‘field’ => ‘slug’,
‘terms’ => array(‘afternoon’),
‘operator’ => ‘IN’
)
),
‘posts_per_page’ => -1
);
$query = new WP_Query($args);
while($query -> have_posts() ) : $query -> the_post();
?>
<h1><?php the_title(); ?></h1>
<?php endwhile; wp_reset_query(); ?>
and this is working, but it’s not the ideal solution. I’d prefer the taxonomies attached to the post type:
<?php
$args = array(
‘post_type’ => ‘classes_camps’,
‘tax_query’ => array(
‘relation’ => ‘AND’,
array(
‘taxonomy’ => ‘category’,
‘field’ => ‘slug’,
‘terms’ => array(‘2018-summer’),
‘operator’ => ‘IN’
),
array(
‘taxonomy’ => ‘post_tag’,
‘field’ => ‘slug’,
‘terms’ => array(‘first-class’),
‘operator’ => ‘IN’
),
array(
‘taxonomy’ => ‘post_tag’,
‘field’ => ‘slug’,
‘terms’ => array(‘afternoon’),
‘operator’ => ‘IN’
)
),
‘posts_per_page’ => -1
);
$query = new WP_Query($args);
while($query -> have_posts() ) : $query -> the_post();
?>
<h1><?php the_title(); ?></h1>
<?php endwhile; wp_reset_query(); ?>
Thanks.