如何显示WordPress中每个类别的帖子数?

我需要在WordPress主题中显示每个类别的帖子数。所以它应该看起来像这样:

  • Cat1(5)
  • Cat2(3)
  • Cat3(2)

数字是帖子数, 因此5表示5类文章在Cat1中, 依此类推。

我写下面的代码:

<ul>
    <?php wp_list_categories( 'orderby=name & title_li' ); ?>
</ul>

那么我应该添加些什么来显示每个类别的帖子数量?


#1


只需添加show_count选项:

<?php wp_list_categories('orderby=name&title_li=&show_count=1'); ?>

如果你想进一步自定义输出, 则还有更多选项:Wordpress Codex上的wp_list_categories

来源:

https://www.srcmini02.com/66546.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_40435.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?