Last active
August 29, 2015 14:27
-
-
Save janisdonis/a42283b57260516235ce to your computer and use it in GitHub Desktop.
Wordpress multi taxonomy query with ACF repeater field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_type' => 'products', | |
'tax_query' => array(), | |
); | |
if(get_field('multi_filter') ) { | |
$temp = array(); | |
while(has_sub_field('multi_filter')){ | |
$_temp = array( | |
'taxonomy' => get_sub_field('taxonomy'), | |
'field' => 'slug', | |
'terms' => get_sub_field('term'), | |
'operator' => 'AND', | |
); | |
} | |
$args['tax_query'] = $_temp; | |
} | |
$query = new WP_Query( $args ); | |
?> | |
<?php if ( $query->have_posts() ) : ?> | |
<?php while ($query->have_posts() ) : $query->the_post(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment