RSS

Top Posts by Category Plugin

Thu, Feb 1, 2007

SEO

One of the things your blog readers don’t have is time. That’s time to wade through your 500 or so posts to pick the golden posts that declare your blog “add to my feed reader” worthy. You need a way to present your top posts up front and you need an easy and automated way to do it. Lucky for you Wordpress fanatics, help is definitely around the corner.

I present to you the Top Post by Category plugin. This baby allows Wordpress bloggers to display their best posts, as determined by the number of visits to the post or number of comments.

Download the plugin here.

You can view my own top posts page (by number of comments) in action here.

Plugin Features

  • You can choose between displaying top visited posts or top commented posts.
  • You can choose to diplay top posts by category or you can display the top posts regardless of category (or as I would like to call it ala Royal Rumble)
  • You can choose to display the actual number of visits or comments for each post featured on the best list.
  • You can control the number of top posts to display, i.e. display N top posts per category.

Installation

  1. Upload to your plugins folder
  2. Activate the plugin.
  3. Go to OPTIONS > Top Post to customize options

How to Insert the Top Posts by Category Code

  • To display your Top Posts list on your sidebar, put <?php tpbc_list ();?> where you want the list to show up.
  • To display your Top Posts list within a page or within a post, edit the particular page or post, then put [ tpbc_list ] (remove spaces) where you want the list to show up.

Extra Bonus

The TPBC plugin uses its own visits counter. To display the “Visited N times” on your post pages like on my blog, just add <?php tpbc_visits (); ?> to your post template.

Comments and Suggestions

Please, by all means, send your comments and suggestions on how to improve this plugin!

Hat tip to my buddy Todd for his best posts page article, the inspiration behind the Top Posts by Category plugin.

And now the fineprint:
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

This post was written by:

Marc - who has written 761 posts on Macalua.com.

Marc is currently Philippine VP of Marketing for U.S. Auto Parts Network Inc. (NASDAQ:PRTS), a Top 200 web retailer as ranked by Internet Retailer Magazine. He breathes SEO, PPC, web analytics, affiliate marketing, email marketing, comparison shopping engines, usability and conversion optimization together with 80 other rising superstars in the Philippine Internet marketing scene. Marc is also the founder of SEO Philippines and is a certified Ateneo Blue Eagle fanatic.

Contact the author

105 Comments For This Post

  1. Andy Beard Says:

    This looks very handy

    I haven’t looked at the code yet, but will it also work with tag pages from UTW, so you have best posts in Tag?

  2. Andy Beard Says:

    Also one thing I forgot to mention. Unless you intend some kind of commercial exploitation, it is quite often easier just to use a GPL license for plugins.

    You don’t have any real copyright / usage clauses there yet, though I haven’t looked at the download package.

  3. Alfredo Says:

    I have been looking for this for months now dude! thanks!

    i tried to use extended live from http://www.sonsofskadi.net/extended-live-archive/ but i cant make it work. right now im using http://www.sporadicnonsense.com/2005/04/28/clean-archives-plug-in/ but i need to sort it in category.

    i noticed that not all posts are displayed here. is it possible to show all my posts?

  4. Swollen Pickles Says:

    Hi
    Where abouts should I add this code to my post template?:

    Cheers

  5. Marc Says:

    Andy, re: UTW integration, will look into providing that functionality for the next upgrade. Also, thanks for the GPL advice :)
    Alfredo, well you can ‘widen’ the net manually by entering a high value in the number of posts to display field.

    SP, which specific code are you talking about?

  6. Swollen Pickles Says:

    Sorry Marc, I cut and pasted the code but it disappeared from my comment once I hit submit. The code I was talking about was the ‘extra bonus’ code.
    Cheers

  7. j4s0n Says:

    Sshhweeettt!!!!

  8. Grant Says:

    Great plugin - already using it but any way to display BOTH lists - top posts by comments AND top posts by views?

  9. David Bradley Science Writer Says:

    Already using this plugin to create a top ten page, I couldn’t figure out how to do that easily with Popularity Contest. But, can one exclude categories from the page, or re-order them? What about excluding individual posts?

    db

  10. Marc Says:

    SP, for my blog I placed it inside the loop of single.php and index.php like so:

    <h2 id="post-<?php the_ID(); ?>"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>

  11. Marc Says:

    Grant, not at the moment, but I’ve queued your request for the next release :)
    David, I’ve received a couple of requests very similar to yours. These functionalities (ability to select/suppress categories and/or posts, customized category order) will definitely be on the next version.

    Thanks for trying out the plugin guys!

  12. Grant Says:

    Marc - I don’t know how you feel about linking other sites but I found another plugin that I’m using with yours to get both or those lists - views and comments.

    here’s the link - http://www.lambic.co.uk/blog/wordpress-plugins

    you can delete this if you want but that you might like to know.

    I use yours for “top by views” and this other one for “top by comments”

    I think your management/dashboard is better.

  13. Marc Says:

    Grant, perfectly all right with me :)

  14. David Bradley Science Writer Says:

    I’ll check back soon for the next version.

    One thing, the page I made doesn’t render Adsense for some reason…I disabled it now, so no need to look, but has anyone else noticed this prob?

    db

  15. Swollen Pickles Says:

    Thanks Marc, I got it working!

  16. Ashish Mohta Says:

    Is it compatible with WP2.1?

  17. Bryan Says:

    Awesome plug-in! Any chance you can make it into a widget?

  18. usws Says:

    Does it show the first time it’s activated? Cause mine doesn’t show at all… not even the [ tpbc_list ] (without the spaces). I’m using WP 2.1 by the way, does it work on that version?

    Thanks in advance!

  19. albert Says:

    howcome when i use
    it does not show up in my sidebar.

    I’m using it in conjunction of the sidebar widgets plugin.

    my site is http://www.vistarewired.com

  20. david Says:

    Good plugin - works perfectly - THANK YOU!

  21. Leroy Brown Says:

    Hmm I set up a page with the
    [tpbc_list] code, and it is showing a blank. Does it take awhile for the plugin to amass stats, as far as which posts are the most popular? I just want to make sure the plugin is acting normally for now.

  22. Everton Says:

    What does it show when a post is submitted to more than one category?

  23. Icaterus Says:

    It’s not showing anything for me either… What’s happening with it?

    This plugin would be really really helpful if I can get it to work :p

  24. Foehammer Says:

    Marc: Big thanks for the plugin! I plopped it in the directory and had it running in 20 seconds flat. That’s great work.

    Running on WP 2.1, K2 based theme with no problems so far.

    I would love a feature to manually input weights on certain posts from the past so that I could instantly bring up old posts. Other than that, the ease with which this installs makes it much easier than dealing with Most Wanted (requires another plugin and patience) or Popularity (won’t run on my customized K2).

  25. Lertad Says:

    I can’t get the code to work either. Is this because of widgets?

  26. laine Says:

    fabulous.

  27. laine Says:

    i have been putzing around with this for a few days now and noticed something that you might want to fix.

    i was working on a long post over the course of the day and noticed that this post was popping up in the list even though it was not published. at first i thought it was only showing it to me since i was logged into my WP install, but even after i logged out it was still there, and to my dismay clicking the link displayed the unpublished post.

    also, maybe adding an option for ip blocking would help?

    one other thing that would be really nice is if you had the option to display your top posts both by visit and by comment count, instead of one or the other. don’t know if it’s feasible, but it would be cool.

  28. Dean Says:

    Hi Marc,

    Great looking plugin but I’m having problems syncing with the db. I’m using wp 2.0.4 and getting the errors seen here: http://blog.abcpsr.com/top-plastic-surgery-posts/

    Can you help? Sorry PHP novice.

  29. Dean Says:

    whoops had to take page down. This was the error I got: WordPress database error: [Table 'abcpsr.wp_tpbc' doesn't exist]

  30. w3top.org Says:

    Here you have my top in case you’re interested
    http://www.w3top.org

  31. benj Says:

    I was so excited to see how it works but I can’t see the display yet. Hmmm.. Does it work on 2.1 (somebody else has already said yes bakit ba ang kulit ko? hehe)

    Im wondering why a lot of 2.1 users are having probs with this one.

  32. Swollen Pickles Says:

    Hey there
    How do I get this plugin to just show certain categories? eg. I don’t want to show the ‘uncategorized’ category cos it seems to be picking up attachments etc.
    see here: http://www.swollenpickles.com/top-posts
    cheers

  33. OSXDaily Says:

    Awesome plugin, wish I knew about this earlier.

  34. Sabo Says:

    wp_tpbc 68,242 MyISAM utf8_spanish_ci 15.9 MiB

    What is this mean? it means that the plugin doesn´t have a FLUSH button to delete the logs, so the database has grow 16MB only in that table.

    Great plugin, but I don´t want my DB weight hundreds of MB just because this plugin.

    Cheers!

  35. ryan Says:

    problem, it publishes drafts. Might not be a problem once a blog is established, but for a new site, unpublished stories should not show up. I also post date a lot of stuff, and it’s showing up

  36. ozpoker Says:

    Hi All

    My problem is it won’t stop. I installed as a php module in sidebar’s modules on K2 and it works except it doesn’t recognise the show “x” posts.

    It just keeps showing all in a long list.

    Help…….please !!!

  37. Mr.Byte Says:

    Yeah i also have the same problem as mentioned by ozpoker. Can I make in the sidebar to list overall top 10 posts and in the top-post page to list it by category?

  38. Haarball Says:

    Hey, is it easy to modify this so that it displays most recent posts instead of most viewed? That would be intensely brilliant.

  39. ozpoker Says:

    I got another prob. now - Top posts is not showing in the sidebar on pages.

    It shows on posts but not pages.

    Any thoughts ?

  40. Baz L Says:

    I have a prob:

    When I enable: Should I group by category?

    It links the Category Heading as the first post….and the first post in the category is not linked.

    HELP.

  41. Raghu Nayak Says:

    Hi man. Its a very cool plugin. Thanks for making it.

  42. Matthew Jabs Says:

    Right now I have my “best of” listed on the top of my left sidebar. Click here to view.

    I also want to create a “Best of” page, but am running into a problem.

    On the best of page I want to list by category…and list the top 5 in each category.

    On the sidebar, I just want to list the top ten overall.

    My problem is…there is only one configuration in the options…and I can’t do both. Is there any way around this?

  43. Gudang Says:

    Thanks dude. This one of the best plugin i’ve ever seen. Gotta try it soon on my website.

  44. Jun Says:

    Hi,

    Congratulations for being a finalist for the Philippine Blog Awards 2007 under the Best Plugin Category.

    I’m Moslemen “Jun” Macarambon Jr. part of the organizing team and committee for the Awards Night.

    I’m making the rounds to gather the contact info and establish direct communication with the finalists. This will give us an avenue to give instructions and other details.

    May we ask for the following please?

    Real Name:
    Email address:
    Mobile Number:
    City and Country where you are based:

    Once this is settled, we’ll know where to communicate the Awards Night details with.

    We hope to hear from you soon. All the best to you and your blog.

    Email me the details here jun [at] wyzemoro [dot] com

  45. littlemoney Says:

    this plugin really rocks!! love it! like it! wanna try it soon!

  46. Lukasz Says:

    Hey is there a way to reset the counter on this plug in, because i want to display top monthly post on my website and would like to reset it every month.

    Thanks

    Great Plugin

  47. latest news Says:

    Very nice plug ins , i all ready installed on my site and working fine , See a New Modify news like cms

  48. Gary Lee Says:

    is there a way to have top posts for each category instead of clumping them all together?

  49. Sasha Says:

    Twas surprisingly easy to use. Good one, Marc! :)

  50. Ray Lao Says:

    thanks so much for this plugin. i love your blog. nice to see such an accomplished blogger who helps other bloggers. and a fellow filipino as well! :)
    thanks again!

  51. Maski Says:

    Well ive been using your excellent plug for some weeks now, and i came across this paradigm.—
    Is there any (easy)way to reset the counter? I would like to reset them to 0 every month or so.

    thanks

  52. Frank Says:

    Hello,
    I’m testing your plugin, but it counts (and sho) also hits on images I have in my pages ?
    Regards
    Frank

  53. Charity Says:

    Hi, I added your plugin to my blog a few days ago and I’ve already noticed improvements to the number of visits I’m getting on older posts. There are some great comments here about extending the functionality too… have you considered an update? Anyway great job and thanks for the plugin. :)

  54. LcF Says:

    does the plugin works perfectly with wp-cache cahed pages?

  55. Wini Says:

    Hi!
    Is there a chance to get the most popular topics from a month, not from a category?

    I want to have a archive page, where i can show my readers the most popular topics each month.

    I Hope you have an idea if it is possible.

    Greetings from Vienna

  56. Joshua Dorkin: TimeforBlogging: Says:

    Thanks for this plugin. I’ve installed it on a few of the blogs I run. Great work!

  57. Edwin Says:

    Excellent plugin.

  58. Wauks Says:

    Wow, nice. Thanks for the great plug-in!

  59. otimização de sites Says:

    Great plug-in! I’ve been looking for something like that for months. Thanks

  60. Baz L Says:

    Got a request:

    Could you somehow rework this for a low DB usage? Do we really need to track IPs, and dates, and times? It’s really killing my database right now. It can’t even be emailed anymore and 85% of the size is due to this plugin.

    Can’t we just have one record for post with a simple counter?

    ThanX

  61. raja Says:

    TQ for the plug in yer

  62. E-Kereta Says:

    i will try this at my blog, tq for your plugin.

  63. Frank Says:

    For some reason I am having a hard time with this. I can not get it to work. What code do I use and where does it go?

    I am confused :(

  64. weirdoux Says:

    Thanks Marc,

    I really love it. I put the visited counter along my title and the Top Post by Category plugin works very well in my single page!

    Thanks again!

  65. Adam Kayce : Monk At Work Says:

    This is perfect, Marc — I was having trouble getting Alex’s Popularity plug-in to do what yours does. It was literally a two-minute install…

    - download
    - unzip
    - upload the one file
    - activate
    - configure in ‘Options’
    - paste code into sidebar.php

    … and it’s looking perfect.

    Thanks so much!

  66. Roger Gordon Says:

    Many thanks for the info

    will be testing out the plugin as a priority on one of my bloggs

  67. recep Says:

    First of all l would likt to thank you about this good tool. l am using it for 3 days. l would like to ask you how to deactive the page visited counter? cos when l checked from crawled index from google “visits” keyword became is the highly the most strong keyword of my site.
    How can l remove the “visits” word from this plugg-in or how can l deactive counter for plugg-in ?
    thanks at all.

  68. recep Says:

    there is no answer for a day ? l am waiting a solution for my request please. no webmaster no mod for this plugin ? No support ?
    thanks.

  69. Zath Says:

    I’ve installed this plugin now and it’s just what I’ve been wanting having been let down by a similar one I tried when it failed to work for me.

    This keeps things simple and does exactly what I need, thanks very much for taking the time to create it!

    Much appreciated!

  70. CeeCee Says:

    Looks like there is no way to select only a specific category and not list all of them.

    Not looking to list all categories just want to be able to select specific categories or place the tag on the sidebar for the category I’m looking to list with the number of posts. Seems like this is what this plugin is lacking.

  71. Wick Says:

    Awesome plugin. Thank you so much. One question … could someone please advise me on how to add the date of the post next to the name of the post? I am a php novice, and I’ve tried about all I can think of.

  72. Aldian Prakoso Says:

    Hi Marc,

    I activate the plugin and paste the code into my side bar, but it doesn’t show. I use WP 2.1.

    Is it not compatible with WP 2.1?

  73. Aldian Prakoso Says:

    Hi Marc,

    The plugin works already.
    I guess it takes time to get the top posts, doesn’t it?

  74. tobe Says:

    Hi, I cant get the plugin to work properly. It inserts incorrect values for “post id” into database, ie always same post id even though different posts were viewed… plz help!

  75. videoke man Says:

    thanks for your plugin ill try this on my site

  76. fil Says:

    Like Baz, I’m concerned by the heavy DB usage. I have 1,573 posts, 30,387 comments and 74,528 tpbc entries. More than 1/4 of my total DB space is taken up by tpbc (12 out of 40MB) and based on a query counter I have, the number of DB queries per page just about doubles when this plugin is active.

  77. opendz Says:

    Great job!
    Anyway, the plugin count my own visits.
    in the funtion tpbc_tracker(), line 81:
    if (is_single () && !is_page ())

    you can change it to:
    if (is_single () && !is_page () && !current_user_can(’edit_posts’))

    This way your visits will not be counted.

    http://opendz.tuxfamily.org/2007/07/21/top-posts-by-category-mais-sans-compter-vos-visites/ (in french)

  78. journeyist Says:

    Your plugin gives me one serious reason to consider switching to wordpres. Hmmmm… sure you don’t plan duplicating this for blogspotties?

  79. Vic Says:

    Thanks for such a great list of plugins, this list are so helpful for the new guy.

    Thanks

    Vic

  80. jetter Says:

    hmmm good plugin. I try to use thing plugin into my site

  81. Tuning man Says:

    Great and excellent plug in t’s realy helpful. Thanks again.

  82. KirkM Says:

    Hi Marc,

    I don’t know if your still supporting this plugin but just for your info, TPBC no longer works with WP 2.3 RC1 due to the deletion of the old pre-WP 2.3 category tables in the MySQL DB in favor of the new taxonomy tables that handle categories now.

    Your plugin and the TPBC page I have on my blog has become quite popular and I’m hoping you might come up with an update. Just wondering.

  83. angie Says:

    Amazing plugin, wish I knew about this earlier.

  84. KC Says:

    Yep, broken in 2.3… please please update!

  85. Gerrit Says:

    Thanks for this amazing plugin, but I also have problems since I updated to Wordpress 2.3.
    Please fix this problem..

  86. Lori Says:

    I have installed the plugin but no posts are showing up. How long does it take for something to show up? I’ve clicking on some of my favorite posts for now trying to get them to show up but nothing. Please advise.

  87. emigre Says:

    Takes a minute or two before the list shows up. I wish the list can be manually selected instead so that I can show the posts I want, and not by most views or comments.

  88. Mr Henree Says:

    Wondering this plugin can be used for wordpress 2.3? If cant, i will hate myself for installing 2.3!

  89. Jeff Says:

    Can you PLEASE get this plugin to work with the latest 2.3 of WORDPRESS? I’m dying to use it!!!

  90. Colleen Says:

    I am using WP 2.3 and it works fine, this is just what I was looking for and more, thanks so much!

  91. NSpeaks Says:

    Please update your plugin for Wordpress 2.3.

  92. Miki Says:

    Hello, I updated this plugin to work with Wordpress 2.3.x.
    You can download it here:
    http://www.miki.cat/index.php/top-posts-by-category-plugin/

  93. Karl Says:

    A couple people on here have been looking for a version which allows category-limitations and I found this one http://wordpress.sobek.pl/sobeks-post-in-category-plugin/ which works great for that purpose.

  94. Inam Says:

    It dont shows the list of top post
    plz help.

  95. Brendon Says:

    I can’t seem to get this plugin to work correctly with Wordpress 2.5 Is it compatible with this version? I don’t receive any error messages when I use the template tag. When I use the Post snippet the actual posts, containing full content, is listed, rather than a bullet list. Thanks!

  96. ALPESH Says:

    Is this plugin compatible with WP 2.5

  97. bariles Says:

    It’s doesnt work with Wordpress 2.5. PLUGIN FAILED. That’s what it said when i activated it. What happened here?

  98. nisti2 Says:

    I’ve just installed and configured but i cannot see my top post and my top post by views please help mee!

  99. Maxoud Says:

    I’ve found a bug with WP 2.5:
    plugin shows posts under wrong categories. It happens when I visit any post and right after that I click on any category this post doesn’t belong to.
    Everything else works fine.

  100. Maxoud Says:

    Sorry, that’s my bug - some mess with taxonomy happened after I imported all posts from 2.0.4 to 2.5.1 using XML

  101. Paul @ Web Design Omagh Says:

    I think WP 2.5 has screwed alot of us with regards displaying top posts. Alex Kings version doesn’t work either.

  102. Chedstone Says:

    You should probably fix this and regenerate the demand for this plugin. It looks like a lot of people would like to use something like this, but no one can because there is no plugin for it. This one doesn’t work.

  103. Amílcar Tavares Says:

    Thus link - http://www.macalua.com/2007/02/01/top-posts-by-category-plugin - does not work…

  104. usws Says:

    Yikesy, i just noticed how big the wp_tpbc table got. Any way I can clean it up? Sorry, if the answer’s somewhere already.. i must be blind. X|

  105. kilwag Says:

    This plugin has worked great for me, easy to install and implement, but the database usage is pretty much forcing me to disable it and look for an alternative. It was great while it lasted though. Thanks.

5 Trackbacks For This Post

  1. How To Make A Reader Your Bitch » Make Money Online at Cash Quests Says:

    [...] a Top Posts plugin and place the list in a prominent [...]

  2. Top Posts By Category mais sans compter vos visites » Open Source DZ Says:

    [...] Top Posts By Category est un plugin qui permet d’afficher (dans la sidebar ou n’importe où) les articles les plus consultés sur votre blog. Seul petit défaut, quand on est l’administrateur du blog on a tendance à visiter régulièrement notre blog (pour des tests ou autres), ces visites faussent les statistiques. Curieusement aucun plugin ne prend en compte ce cas de figure. En conséquence, j’ai donc modifié ce plugin. [...]

  3. Compilation of the Best Wordpress Plugins available Says:

    [...] Top Posts by Category - Shows top posts by category, comments, etc. (Similar to Popularity Contest) [...]

  4. View the Most Viewed Posts Says:

    [...] this sweet plugin that displays the top posts of each category, sorted by the number of visits. (You can also choose to sort it by number of comments [...]

  5. Populārāko Ierakstu Spraudnis | Ingas Blogs Says:

    [...] arī jums gribās uzinstalēt šo spraudni, te nu būs mazliet informācijas. Spraudnis, saukts “Top Posts by Category Plugin”, ir ērti un viegli instalējams (kā jau pārsvarā visi WP spraudņi). Statistiku var [...]

Leave a Reply