Created
September 8, 2015 15:09
-
-
Save janisdonis/91c981bad140479091ed to your computer and use it in GitHub Desktop.
Tax custom 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 ); | |
?> |
martins-giberts
commented
Sep 8, 2015
'products',
'tax_query' => array(
'relation' => 'AND',
),
);
```
if(get_field('multi_filter') ) {
while(has_sub_field('multi_filter')){
$args['tax_query'][] = array(
'taxonomy' => get_sub_field('taxonomy'),
'field' => 'slug',
'terms' => get_sub_field('term'),
);
}
}
$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