Like that should be work:
<table style="margin:0px;">
<?php
$taxonomy_name = "Brand";
$terms = get_terms(array(
'taxonomy' => $taxonomy_name,
'hide_empty' => false,
));
foreach ($terms as $term)
{
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_stock_status',
'value' => 'outofstock',
)
),
'tax_query' => array(
array(
'taxonomy' => $taxonomy_name,
'field' => 'term_id',
'terms' => $term->term_id
)
)
);
$query = new WP_Query($args);
echo "<tr style='list-style:none;'>";
echo "<td style='width: 200px'>$term->name</td>";
echo "<td style='width: 200px'>$term->count</td>";
echo "<td style='width: 200px'>$query->found_posts</td>";
echo "</tr>";
}
?>
</table>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…