如何使用以下函数在每个列出的类别之后进行帖子计数?此外,我如何将其应用于wp\\U get\\U存档,以及与以下功能相同的选项?
<ul>
<?php
$args = array(
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'number\' => 10, // how many categories
);
$categories = get_categories($args);
foreach($categories as $category) {
echo \'<li><a href="\' . get_category_link( $category->term_id ) . \'" title="\' . sprintf( __( "View all posts in: %s" ), $category->name ) . \'" \' . \'>\' . $category->name.\'</a> ›</li>\';
}
?>
</ul>
示例:
|(get\\u类别)
类别项目1>()
类别项目2>()
(wp\\U get\\U存档)
存档项目1>()
存档项目2>()
最合适的回答,由SO网友:Shazzad 整理而成
用于在循环中显示类别计数-
foreach($categories as $category) {
echo \'<li><a href="\' . get_category_link( $category->term_id ) . \'" title="\' . sprintf( __( "View all posts in: %s" ), $category->name ) . \'" \' . \'>\' . $category->name.\'</a> › (\'. $category->count .\')</li>\';
}
用于显示计数
wp_get_archives
函数,在参数中使用show\\u post\\u count-
wp_get_archives( array( \'show_post_count\' => true ));