Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

Thanks

like image 669
Steffi Avatar asked Mar 10 '11 12:03

Steffi


People also ask

How do I count the number of posts in WordPress?

Simply copy the [sbs_posts] shortcode and add it to any WordPress post, page, or shortcode enabled sidebar widget. It will show the total number of published posts on your WordPress site. You can also use [sbs_blog_stats] which will show all blog stats including the total number of posts.

How do you find the number of tags?

Perhaps the easiest way to get the total number of tags is to open PI System Management Tools (aka PI SMT) and navigate to the 'Points' tool in the lower left pane. Expand it to locate the 'Point Source Table'. Here you will find your pi points count by point source.

How do I count categories in WordPress?

Easy way to count category is: 1) firstly fetch all category from wordpress 2) count them using simple php funciton complete code will be like: <? php $args = array( 'parent' => 0, 'hide_empty' => 0 ); $categories = get_categories( $args ); echo "Total categories : ". count( $categories ); ?>

How many tags should I use on WordPress post?

By default, there is no limit to the number of tags you can assign. But a post with a lot of tags may not look good in your WordPress theme. We say add no more than 10 tags to your posts unless you can justify it.


2 Answers

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;
like image 110
Foxinni Avatar answered Oct 04 '22 04:10

Foxinni


See here.

  • Wordpress - Get number of posts AND comments by day
  • Get number of posts belonging to a particular category,
like image 30
Saurabh Gokhale Avatar answered Oct 04 '22 03:10

Saurabh Gokhale