我想显示一个类别列表,其中每个类别中当前的帖子数取决于所选标签。
例如,如果选择标签 A(已标记 2 个帖子),则类别列表将为:
- cat A (2)
-- cat Aa (1)
-- cat Ab (1)
如果选择标签 B(已标记 3 个帖子):
- cat A (3)
-- cat Aa (1)
-- cat Ab (1)
-- cat Ac (1)
由于无法在 wp_list_categories
的参数中指定标签,您有关于如何处理的想法吗?
谢谢
最佳答案
您有一堆可以应用 wp_list_categories 函数的参数。其中之一是 show count,它是一个 bool 值 0 -> false,1 -> true。还要检查 child_of 参数。
$args = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '',
'exclude_tree' => '',
'include' => '',
'hierarchical' => 1,
'title_li' => __( 'Categories' ),
'show_option_none' => __( '' ),
'number' => null,
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => null
);
wp_list_categories( $args );
https://codex.wordpress.org/Template_Tags/wp_list_categories
关于wordpress - wp_list_categories 取决于所选标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33433218/