Group posts that matches a term in a loop
This is my best approach: Store the values in an array during the while loop, and then using array_count_values php function, you obtain the desired output. It is untested, but I think it should work: if ( $query->have_posts() ) { //in this variable, declared as an array, we will store the values $products_array = array(); … Read more