wp count terms 统计分类法中的分类项目数量

文 / @WordPress主题

WP Count Terms 函数

我今天来介绍一个有用的WordPress函数:wp_count_terms()。本函数返回指定分类法的分类项目总数。

描述

wp_count_terms()在统计分类法中有多少个分类项目方面非常有用。默认$args为‘hide_empty’,可以为‘hide_empty=true’或array('hide_empty'=>true)。

使用方法

<?php wp_count_terms($taxonomy,$args); ?>

参数

$taxonomy
(string)(必需)分类法名称。
默认:string
$args
(mixed)(可选)覆盖默认参数,查阅get_terms()。
默认:array/string

返回值

(int)
$taxonomy的分类项目总数。

希望这个函数对你来说也是有用的。如果你有任何问题,请在评论中告诉我。

添加UTHEME为好友
扫码添加UTHEME微信为好友
· 分享WordPress相关技术文章,主题上新与优惠动态早知道。
· 微信端最大WordPress社群,限时免费入群。