I am trying to only post one post of each custom taxonomy APP_TAX_STORE
my wp_query
looks like this:
// show all alternative active coupons for this category from related store
$tax = get_the_terms($id, 'coupon_category');
$args = array(
'post_type' => APP_POST_TYPE,
'post_status' => 'publish',
'posts_per_page' => 5,
'meta_key' => 'clpr_topcoupon',
APP_TAX_TAG => 'gutschein',
'orderby' => array(
'meta_value_num' => 'DESC',
'post_date' => 'DESC',
),
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'coupon_category',
'field' => 'slug',
'terms' => $tax[0]->slug,
),
array(
'taxonomy' => APP_TAX_STORE,
'field' => 'slug',
'terms' => $term->slug,
'operator' => 'NOT IN',
),
),
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) :
$query->the_post();
get_template_part( 'loop', 'coupon' );
endwhile;
wp_reset_postdata();
Now I need to tell the loop to only show one post of each APP_TAX_STORE
(taxonomy).
I do know that I probably need a second query and that I have to combine then. However I tried so many solutions from this forum that I am know totally lost.
With this query I can call one post of each APP_TAX_STORE
$terms = get_terms(array('taxonomy' => APP_TAX_STORE));
foreach ($terms as $term){
$args = array(
'post_type' => APP_POST_TYPE,
'posts_per_page' => '1',
'order_by' => 'date',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => APP_TAX_STORE,
'field' => 'slug',
'terms' => $term->slug,
)
)
);
$new_query = new WP_Query ($args);
if ($new_query->have_posts()) {
while($new_query->have_posts()){
$new_query->the_post();
get_template_part( 'loop', 'coupon' );
}
}
}
Now I need to combine these!
Really appreciate some help!