如何计算父类别的子类别数?我使用的是一种自定义分类法,称为“作者”。
我找到了这段代码,它确实统计了子类别的数量,但只在全局范围内,而不是某个特定父类别的数量。
$num_cats = wp_count_terms(\'authors\');
$num_parent_cats=count(get_categories(\'parent=0&hide_empty=0\'));
$num_child_cats = $num_cats-$num_parent_cats;
echo \'<p>number of child categories: \' . $num_child_cats . \'</p>\';
资料来源:https://wordpress.org/support/topic/child-category-count