获取帖子计数为 0 的 WordPress 标签



我正在尝试从wordpress数据库中获取一些标签,这些标签没有分配给任何帖子,因此它们的帖子计数为0。 我使用的代码只选择分配了 1 个或多个帖子的标签......

<?php
$args = array(
'smallest'                  => 12,
'largest'                   => 24,
'unit'                      => 'px',
'format'                    => 'flat',
'orderby'                   => 'name',
'order'                     => 'DESC',
'exclude'                   => null,
'include'                   => null,
'topic_count_text_callback' => 'default_topic_count_text',
'link'                      => 'view',
'taxonomy'                  => 'post_tag',
'echo'                      => true,
'child_of'                  => null,
'show_count' =>1
);
?>

如何获取分配了 0 个帖子的标签?

在 get_tags 函数的参数中将hide_empty设置为 false。

get_tags(array('hide_empty' => false));

如果使用自定义分类,请使用get_terms函数。

get_terms('custom_tags', array('hide_empty' => false));

最新更新