• I’ve spent a couple of hours trying to figure out how to do this but I’m really struggling so I hope someone can help me on here. I basically want to display (in the sidebar on every page) the number of posts in a particular category for the current year (categoery ID is 13, name is Call Outs). I found this bit of code:

    <div>
    Call outs this year:
      <?php
        $category = get_the_category();
        echo $category[0]->category_count;
      ?>
    </div>

    I assumed that if I changed the [0] to 13 then it would display the number of posts in that category, but that’s not the case. Can anyone help? It seems like such a simple thing but it’s doing my head in!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Display number of posts in category for current year’ is closed to new replies.