开发者

Wordpress : How to count number of posts on a tag

I have a question.

How can I count number of posts of a tag ?

Example : Tag photos (67)

Tha开发者_高级运维nks


Use the code below:

$taxonomy = "category"; // can be category, post_tag, or custom taxonomy name

// Using Term Slug
$term_slug = 'some-category';
$term = get_term_by('slug', $term_slug, $taxonomy);

// Fetch the count
echo $term->count;


See here.

  • Wordpress - Get number of posts AND comments by day
  • Get number of posts belonging to a particular category,
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜