$filter = array(
'post_type' => 'portfolio',
'post_status' => 'publish',
'offset' => 0,
'tax_query' => [],
'meta_query' => [],
);
$data = [];
$data[1] = [];
foreach ($enabled as $v) {
foreach ($v['option'] as $o) {
$filt = $filter;
if ($v['type'] == 'select') {
$filt['meta_query'][] = array(
'key' => $v['name'],
'value' => $o
);
}
else if ($v['type'] == 'taxonomy_checkbox') {
$filt['tax_query'][] = array(
'taxonomy' => $enabled_values[ $v['name'] ]['taxonomy'],
'field' => 'term_id',
'terms' => $o,
'operator' => 'AND'
);
} else {
$filt['tax_query'][] = array(
'taxonomy' => $enabled_values[ $v['name'] ]['taxonomy'],
'field' => 'term_id',
'terms' => $o,
'operator' => 'IN'
);
}
$data[1][$v['name'].'_'.$o] = (new WP_Query( $filt ))->found_posts;
}
}
var_dump($data, round(microtime(true) - $start, 4));