Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在前端显示WooCommerce产品标签的数量?_Php_Wordpress_Woocommerce - Fatal编程技术网

Php 如何在前端显示WooCommerce产品标签的数量?

Php 如何在前端显示WooCommerce产品标签的数量?,php,wordpress,woocommerce,Php,Wordpress,Woocommerce,我需要在前端打印出WooCommerce的产品标签总数 比如: 我们有不同品牌的产品 其中“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu <?php $term_count = wp_count_terms('pa_brand'); echo sprintf('We have products from %d different brands

我需要在前端打印出WooCommerce的产品标签总数

比如:

我们有不同品牌的产品


其中“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu

<?php

$term_count = wp_count_terms('pa_brand');

echo sprintf('We have products from %d different brands', $term_count);

?>

简单而好的答案,但也包括
wp\u count\u terms()
的链接以供进一步参考。非常感谢。如何找出slug WooCommerce用于产品标签?进入Products->Attributes,表格中有一列是slug,用它来标识您希望使用的slug。也许您误解了我的意思。我不想计算像“颜色”或“大小”这样的属性,而是我用于品牌的“产品标签”。如果是这样,产品标签是一种分类法,所以使用
wp\u count\u terms('product\u tag')
,它会给你正确的结果。如果有效,请将其标记为正确答案。
<?php

$term_count = wp_count_terms('product_tag');

echo sprintf('We have products from %d different brands', $term_count);

?>