我正在使用这段代码来显示某个分类中的类别列表,以及该类别中的帖子数量。
每当我删除帖子时,帖子计数仍包括已删除的帖子并显示该类别标题,这也适用于已放入草稿的帖子。直到我永久删除该类别和/或计数消失的帖子。
我错过了什么?
<?php $args = array(
'show_option_all' => '',
'orderby' => 'slug',
'order' => 'ASC',
'style' => 'list',
'show_count' => 1,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( '' ),
'show_option_none' => __('No categories'),
'number' => null,
'echo' => 0,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'artists',
'walker' => null
);
$variable = wp_list_categories($args);
$variable = preg_replace('/\<\/a\> \((.*)\)/',' <span class="quantity">$1</span></a>',$variable);
echo $variable;?>