Category Post Count

Wednesday, October 20, 2004, 11:01 pm

I stole a few lines from GaMerZ’s WP-Stats plugin and repackaged it into a Category Post Count plugin [see the sidebar] that enables you to display the number of posts in each category on the right side of the list.

If you’re interested in using the plugin post a comment or email me!

Here’s the code, copy and paste into a text editor and save as cpcount.php, then upload to your plugins directory and activate from your WP panel.

Update: Apparently WP comes with a built-in feature to do this [my bad!], but mine is presented in a slightly different visual style! ๐Ÿ˜›

{ 13 comments… read them below or add one }

Naina October 20, 2004 at 11:41pm

Hi there – I would love to have the plugin…
Thanks in advance!


Mr. Dew October 20, 2004 at 11:50pm

you can use
<?php list_cats(‘optioncount=1’); ?> i think


Julia Williams November 22, 2004 at 10:21pm

Thanks, I’ve been looking for something like this. I tried to move the count a little to the left, though, and couldn’t figure that one out, but I do love having the count.


JErm November 22, 2004 at 10:32pm

NP Julia, glad to have helped! ๐Ÿ˜€

You could move them a little to the left by adding non-breaking-spaces [ ] next to the count, or by padding the right side of the post count div by a few pixels.


Lashundra December 29, 2004 at 9:17pm

I clicked on the link to get the copy to copy & paste into a text editor but it gave me page not found. Would you please email me the code at the email addy listed?



JErm December 29, 2004 at 11:28pm

Sorry about that, I have the link fixed now! :)


Lashundra December 30, 2004 at 3:50am

thanks jerm for the code, hopefully i’ll be able to follow the simple instructions to make it work.

happy new years!


JErm December 30, 2004 at 11:25am

Good luck.. if you find any problems feel free to drop by again later! :)


Tracy April 8, 2005 at 10:15pm

I downloaded your plugin/hack and installed. It shows the number of posts in each category, BUT it takes away the link to each category…. the cat # is gone and link to nowhere…. any ideas?? also, is there a way to do it so the number of posts – the count – is in (23) brackets??


JErm April 8, 2005 at 11:03pm

Tracy, that plugin was made for 1.2 so I don’t know if it still works; apparently not.. hehe.. I’ll drop you an email if I get a chance to fix it for 1.5, and I’ll look into the brackets thing, but I think WP has that feature by default now.


Madolyn May 23, 2005 at 10:46pm

Please humour a complete idiot… I need to pass two arguments, so would the following be correct?


Madolyn May 23, 2005 at 10:47pm

Damn, let me ask that again…
<?php wp_list_cats(‘sort_column=name’,’optioncount=1′); ?>


JErm May 24, 2005 at 11:41am

Madolyn ยป I think so but you better check the WP Codex to make sure.


Leave a Comment