Support

Account

Home Forums General Issues Help with query posts filtered by multiple field values Reply To: Help with query posts filtered by multiple field values

  • Ok cool, I’m glad I’m making sense!

    I’m using an acf select field, configured like this:

    Field Name: q_and_a_category_select
    Field Type: Select

    Choices
    design : Design
    engineering : Engineering
    project-management : Project Management

    To fill you in on the history, originally I had three separate page templates, each displaying posts from a specific term. For example, I used this for the Design page:

    <?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(); ?>

    This works great to show just the q-and-a custom posts assigned the term “design”, but I didn’t want to have separate templates for each one.

    So the first thing I tried was this:

    ‘q_and_a_category’ => ‘<?php the_field(“q_and_a_category_select”); ?>’

    I figured it would simply just plug in the proper term and I’d be good to go. But it didn’t work and I’m not skilled enough in php to know why not.

    So I did some searching and found this acf tutorial: http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values

    Seems like example 3 should do it, but no luck.

    Thanks again!