I have the following:
custom post type: q-and-a
custom taxonomy: q_and_a_category
taxonomy terms: design, engineering, project-management
I'm creating three separate pages that filter the custom post types by their terms. I.e., one page for Design, one for Engineering, and another for Project Management.
I'm accomplishing this with three separate page templates, like this:
<?php
$args=array(
'post_type' => 'q-and-a',
'q_and_a_category' => 'design' //the slug for the custom taxonomy term
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();
?>
<?php the_title(); ?>
<?php endwhile; }?>
<?php wp_reset_query(); ?>
But I'm trying to create a single page template where the taxonomy term is inputted via a "select" menu that I've set up using advanced custom fields.
I tried following the ACF plugin tutorial for this, example 3:
Like this:
<?php
// args
$args = array(
'numberposts' => -1,
'post_type' => 'q-and-a',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'q_and_a_category',
'value' => '%design%',
'compare' => 'LIKE'
),
array(
'key' => 'q_and_a_category',
'value' => '%engineering%',
'compare' => 'LIKE'
),
array(
'key' => 'q_and_a_category',
'value' => '%project-management%',
'compare' => 'LIKE'
)
)
);
// get results
$the_query = new WP_Query( $args );
// The Loop
?>
<?php if( $the_query->have_posts() ): ?>
<?php the_title(); ?>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
When I try this, the page loads on the front end but no posts are displayed.
Any suggestions? Thanks in advance.