Support

Account

Home Forums General Issues Filtering a loop with taxonomy field Reply To: Filtering a loop with taxonomy field

  • Hi @herrfischer

    Hmm… I believe you should be able to accomplish this using a tax_query in WP_Query. For example, the following code will query posts that are in the red and vegetable category:

    $args = array(
    	'post_type' => 'post',
    	'tax_query' => array(
    	array(
    		'taxonomy' => 'category',
    		'field'    => 'slug',
    		'terms'    => array('red', 'vegetables')
    	),
    	),
    );
    $query = new WP_Query( $args );

    For more information, have a look at: https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

    Hope this helps 🙂