Repeat array inside array through while loop

Start by creating the arguments, but leaving tax_query empty: $args = array( ‘post_type’ => ‘watches’, ‘tax_query’ => array(), ); Then in your loop you can add to tax_querywith $args[‘tax_query’][] =: $args = array( ‘post_type’ => ‘watches’, ‘tax_query’ => array(), ); foreach ( $things as $thing ) { $args[‘tax_query’][] = array( ‘taxonomy’ => $thing[‘taxonomy’], ‘field’ => … Read more

How do if all posts has this category ID then do this

You can use get_category( $id ), the object it returns includes a count of posts contained in this category. To build on your example, this would be: $my_category = get_category( ’25’ ); if ( 1 <= $my_category->category_count ) { echo “OK”; } else { echo “NO OK”; }