Counting how many posts are filed under one tag
-
Hi!
On the archive page, I want to display how many posts are covered by the relevant category / tag archive.
The following code shows the number of posts of a category:
<div class="archive_number"> This category contains <?php $cat = get_the_category(); $cat = $cat[0]; echo $cat->category_count; ?> posts </div>
Now, I want to display the number of posts filed under a tag. I’ve tried it with the following code:
<div class="archive_number"> <?php $tag = get_query_var('tag_id'); $tag = $tag[0]; echo $tag->tag_count; ?> posts are filed under this tag. </div>
But (of course) this does not work. Any ideas what I do wrong? Be patient, I’m a php n00b.
Thanks for your help.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Counting how many posts are filed under one tag’ is closed to new replies.