WordPress Plugin: Smart Unread Comments

Filed under: Blogging,Software,WordPress Plugins — Brett @ February 11, 2005 7:52 pm

As seen on Webfroot and this site, now in WordPress Plugin form!

Current Version: 1.3

What it does
Creates a list of posts with comments that haven’t been read by the user since their last visit/session. Uses cookies to track users last visit – no database required!

How it works:
Users are issued cookies which are used to track last visit. If this is their first visit, all comments in the last 14 days are unread. The plugin generates a list of unread comments. It keeps track of the user’s read posts for the session, removing them from the list as the user goes. Each page load updates the last unread timestamp cookie. Users can also mark all comments as read.


In your template, add this code.

<ul><?php echo get_smart_unread_comments(); ?></ul>

get_smart_unread_comments() also takes options:

  • $limit
    Default: 5.
    Maximum posts with unread comments to display.
  • $output_when_no_unread_comments
    Default: TRUE
    If true, when there are no unread comments, it will output a <li class="wbftSUC_NoComments" > item containing $no_unread_comments_text
  • $output_when_more_unread_comments_than_limit
    Default: TRUE
    If true, when there are more than $limit unread comments, it will output a <li class="wbftSUC_MoreComments" > item containing $more_unread_comments_text
  • $mark_comments_as_read_text
    Default: “Mark all comments as read”
    String used in link Mark all Comments as Read link.
  • $no_unread_comments_text
    Default: “There are no unread comments”
    String used when there no unread comments and $output_when_no_unread_comments is TRUE
  • $more_unread_comments_text
    Default: “There are %d more unread comments…”
    String used when there are more than $limit unread comments and $output_when_more_unread_comments_than_limit is TRUE
    %d will be replaced with a count of how many more comments there are to view.

You’re looking at it!

CSS Classes output:
Remember, CSS classes are CASE SENSITIVE.

  • class='wbftSUC_MarkAsRead'
    Used on the Mark Comments as Unread link
  • class='wbftSUC_Recent'
    Used on comments less than 6 hours old
  • class='wbftSUC_MoreComments'
    Used on More Unread Comments list item
  • class='wbftSUC_NoComments'
    Used on No Unread Comments list item

Version History:
1.3: Now uses permalink structure, and sets cookies to your blog’s path. $limit defaults to 5 (not 10), and $output_when_more_unread_comments_than_limit defaults to TRUE.
1.21: Fixed broken (x)html validation due to stray
1.2: Fixed major bug with post title links.
1.11: Tables are now pulled from WP variables.
1.1: Initial Public Release.

Known Issues:
Comments on Pages (as opposed to posts) turn up on the list, but visiting the Page doesn’t mark those comments as unread.


  • Chris Beaven (aka SmileyChris) for writing the original code seen on Webfroot, and helping with updating it.
  • Dan aka Mufasa and Tom for isolating the code from Chris’s Webfroot code magic and encouraging Me to write it.
  • Brett Taylor (Me! aka Glutnix) for turning it into a WP plugin and making the number of unread comments on each post link to the oldest unread comment rather than the newest unread comment.

Bugs and Suggestions
Any bugs or suggestions, please email me – email link in the sidebar (RSS readers: drop by the site ;) ).


  • [...] gs   Even better than the Smart Unread Comments functionality on Webfroot! Smart Unread Comments displays a list of posts with comments unr [...]

    #1: Pingback by Webfroot » WordPress Plugin: Smart Unread Comments — February 11, 2005 @ 8:11 am

  • Hi,

    This seems pretty good, but it breaks if the table prefix in the DB is anything other than “wp_” (because it’s hardcoded).

    I think you want to get hold of $table_prefix somehow, but I’m not altogether sure how.



    #2: Comment by Carl — February 12, 2005 @ 4:00 am

  • It seems there is another bug. The cookies do not register on WP 1.5 Pages.

    #3: Comment by Victr — February 12, 2005 @ 4:38 am

  • Comment!

    #4: Comment by Brett — February 16, 2005 @ 11:59 am

  • For some reason, the /?posts_timeout=1 link just returns a blank page and doesn’t mark all comments as read? Any ideas?

    #5: Comment by William — March 1, 2005 @ 9:10 am

  • Hi Brett, since this plugin doesn’t work with permalinks, is there a fix in the works, or can you provide me instructions on what I need to modify to make it work?

    #6: Comment by Ken — March 3, 2005 @ 4:46 pm

  • Yes, it’s a known issue that the plugin doesn’t use your permalink structure. Even so, it should still work, as it works here on inner.geek and on Webfroot.

    I haven’t looked into how to fix it — is there a function that will generate the permalink from a post_id?

    #7: Comment by Brett — March 4, 2005 @ 8:20 am

  • Right now, whenever I click on one of my links for unread comments, it takes me to my root index page. Hmm. Sorry, don’t know about the function you’re looking for. I’m still fairly new to this.

    #8: Comment by Ken — March 4, 2005 @ 8:29 am

  • I had to go through your code and change every instance of




    to make it work with my blog (because the root of my blog isn’t /).

    #9: Comment by Paul Tomblin — March 6, 2005 @ 11:58 am

  • Looks like someone messed up the description for your plugin on

    #10: Comment by Krischan — March 9, 2005 @ 9:39 pm

  • Hey Brett, I’m not sure the $output_when_more_unread_comments_than_limit option works. Or rather, I don’t think it’s working for me. It seems to just follow whatever $limit is. If I set $limit to 15, clear my cache and reload, I get 15 comments and $more_unread_comments_text says that there are 15 more unread comments. If I change $limit to 14, it displays 14 comments & says I have 14 more unread, etc.

    Oh, and not to start off w/ something negative. I love the plugin. Great job. I’m just wondering if you know what’s going on there, if that’s expected, or what.

    #11: Comment by Brak — March 11, 2005 @ 9:28 am

  • [...] t whatever you find most useful at the top. Search upfront, then one of the new features, Unread Comments. This will allow you to, at a glance, see if the [...]

    #12: Pingback by jonabad.com » New Features — April 15, 2005 @ 6:33 pm

  • Brett, I’m curious if you’ve taken a look at making different links for Pages that get comments. When a page with a comment gets listed in the plugin, i get a link that looks like this
    and then when clicking it, I get “no posts matched your criteria”

    I was thinking of taking a look at the posts table to see how to go about segregating Pages out of the results. I personally want them to be listed but I can also see how others may not.

    #13: Comment by Jon Abad — May 15, 2005 @ 6:40 am

  • [...] tus field called “Show on front page” which will be checked by default for all posts. Smart Unread Comments Creates a list of posts wi [...]

    #14: Pingback by FrosBlog.com » Plugins — May 29, 2005 @ 1:07 pm

  • zz85: yeah, it’s a known issue. Will resolve it when I get some time to nut out why it’s treating pages differently.

    #15: Comment by Brett — May 31, 2005 @ 10:18 pm

  • [...] tch” Another “must have” cool plugin. It has just been updated to v1.3 http://inner.geek.nz/archives/2005/02/11/wordpress-plugin-smart-unread-comments/ 2 Issues I faced. Doesnt work with pages Almost destroy the layo [...]

    #16: Pingback by kepo-ing Zz85 » Blog Archive » Smart Unread Comments “patch” — June 1, 2005 @ 5:18 am

  • Just another bug I noticed (maybe only for me :( ) is that the I keep seeing “There are 1 more unread comments…” when there are actually more than that. So after clicking on one unread comment, then will i see another 1 unread comment appearing.

    after removeing /* */ around is_page(), the page comments get removed but only after 1 more extra page load. Using “Mark all comments as read” works well.

    #17: Comment by zz85 — June 1, 2005 @ 11:08 pm

  • [...] and I had to change it to the Most Wanted plugin. Another plugin that I activated is the Smart Unread Comments which allows my readers to [...]

    #18: Pingback by …in the outer… » More Blog Renovations — July 17, 2005 @ 7:11 pm

  • Whenever I’m on one of my pages (like my about me page) it shows comments that I’ve already read, and clicking on the “mark comments as read” link doesn’t seem to do anything. I thought it might have been a known issue, but when I tried it here on your site it worked fine. Actually, even after reading the comments, going back to the index it still shows them as read, I have to manually mark them as read. Did I goof up somewhere, somehow?

    #19: Comment by Steph — July 20, 2005 @ 8:01 pm

  • Ok, I fixed the link not doing anything problem. Like someone else mentioned, my blog isn’t in the root either, it’s in /blog/ so I just had to add the / in the url for the mark comments read link, seems to have fixed that part. :D

    #20: Comment by Steph — July 21, 2005 @ 4:40 pm

  • [...] cevoir les mise à jour par courriel, vous ne les verriez pas. Alors j’ai ajouté un plugin qui affiche les derniers commentaires que vous n’av [...]

    #21: Pingback by bumpert’s home » Blog Archive » Commentaires non lus — August 10, 2005 @ 7:30 am

  • [...] Blog Archive » WordPress Plugin: Smart Unread Comments Published 0 minutes ago inner.geek » Blog Archive » WordPress Plugin: Smart Unread Comment [...]

    #22: Pingback by cordac - in da flesh » inner.geek » Blog Archive » WordPress Plugin: Smart Unread Comments — August 17, 2005 @ 7:10 pm

  • Maybe it’s some kind of issue, but when I modify the plugin to show the 3 last comments to show it displays 4, when I do it for 4 it displays 5 … is that normal?

    #23: Comment by Rodrigo — August 27, 2005 @ 6:49 pm

  • This seems to be a nice plugin. The idea is good… it would be nice to have this integrated in the admin panel, however.

    #24: Comment by Luis Almeida — September 28, 2005 @ 8:02 am

  • Great plugin. Tons of help.

    The SQL queries broke for me on custom 404 pages, so I added a check for !$postid on lines 45 & 71.

    Couldn’t hurt to throw it in — or if anyone else has that problem.

    #25: Comment by Dick Masterson — September 30, 2005 @ 9:32 am

  • [...] dpress/spam-karma CG-Amazon http://www.chait.net/index.php?p=238 Smart Unread Comments http://inner.geek.nz/archives/2005/02/11/wordpress-plugin-smart-unre [...]

    #26: Pingback by Tannagh - TechGnome’s World » Blog Archive » Tannagh - Kildare Template — October 1, 2005 @ 3:42 pm

  • [...] dpress/spam-karma CG-Amazon http://www.chait.net/index.php?p=238 Smart Unread Comments http://inner.geek.nz/archives/2005/02/11/wordpress-plugin-smart-unre [...]

    #27: Pingback by Tannagh - TechGnome’s World » Tannagh - Kildare Template — October 1, 2005 @ 3:43 pm

  • I’ve added this plugin to my daughters blog and it works as expected with IE – but Firefox doesn’t seem to.

    Clicking mark as read doesn’t seem to do anything, but if I then view some of the coments returning to the home page says “There are no unread comments”. However closing Firefox and then restarting and returning to the site lists all unread comments again.

    Opera seems to very nearly work – just the mark all as read option not working.

    Any suggestions? Is oit Firefox settings or a bug?

    #28: Comment by FogCat — October 8, 2005 @ 12:57 pm

  • Just a quick note and a thanks for the plugin. Got it integrated into my new theme design and it looks just grand.


    #29: Comment by TechGnome — October 12, 2005 @ 9:49 am

  • No matter how many unread comments there are, it always returns there is 1 more unread comment. Is the number too large for the first visit?

    #30: Comment by Brian Bonner — November 4, 2005 @ 11:26 am

  • [...] neric Recent Comments tracker in the sidebar, a new Unread Comments tracker (thanks to the Smart Unread Comments plug-in) shows only the comments you haven [...]

    #31: Pingback by The Robservatory » New comment tools installed… — December 8, 2005 @ 8:22 am

  • [...] have also introduced an unread comment section using the Smart Unread Comments plugin from inner.geek I ran across today in The Robservatory. It’s p [...]

    #32: Pingback by bluefacedpixie » Not reading comments? — December 8, 2005 @ 8:19 pm

  • [...] , голямо нещо Друг плъгин, който много ме радва, е [...]

    #33: Pingback by Дни » Blog Archive » — December 26, 2005 @ 8:32 am

  • [...] , голямо нещо Друг плъгин, който много ме радва, е [...]

    #34: Pingback by Дни » Blog Archive » Окончателности разни — December 26, 2005 @ 8:32 am

  • [...] anzeigt – wie zB in Foren als eingeloggter User – hatte ich bisher nicht gefunde. Bisher. Smart Unread Comments macht exakt das: Creates a list of posts w [...]

    #35: Pingback by Basic Thinking Blog » Wp-Plugin: Smart Unread Comments — December 28, 2005 @ 1:53 am

  • Hi, have you ever thought of making a “recent posts” plugin? Should be quite easy I guess, just tweaking a little. There are a lot of recent posts plugins, yet I’ve found none with that “smart” useing cookies. I’m not into php-programming, I’d take ages for me to alter your plugin for posts… (so in case you do, let me know ;-) )

    #36: Comment by mzeecedric — December 28, 2005 @ 12:27 pm

  • [...] Show what’s new – forums have done this well in the past by indicating the number of new comments since your last visit. Drupal offers this for all commented on content. There’s a WordPress plugin for unread comments. Of course, comment RSS feeds or email notifications can be used to track new comments on posts that interest you too. [...]

    #37: Pingback by Improving the readability of large numbers of comments — cre8d design blog — January 28, 2006 @ 4:11 pm

  • Hey, just found your plugin through Google. Wow, looks pretty nice! I’m running WP 2.0 RC3 with some plugins involved, I’ll give it a spin tomorrow. I just wanted to comment on mzeecedric’s suggestion for a similarly “intelligent” recent posts plugin. I agree very much. Features that are enhancing a visitor’s surfing experience are very welcome.
    [ Okay, now I'm thinking of something like "Hello XX - 10 Posts, that you haven't read here but might interest you, sorted by popularity:", but that's another story. ;) ]
    Keep up the good work! I’m just writing a little article on the IMHO best “customizable post listing” plugins, including e.g. “Popularity Contest”. I’ll look into yours as soon as I can.

    #38: Comment by Karsten — February 10, 2006 @ 1:35 pm

  • [...] I’ve installed the Smart Unread Comments plugin at the top of the posts area, which should allow my visitors to see any new comment posts since their last visit, provided they’re using cookies. [...]

    #39: Pingback by Jim’s Weblog » Smart Unread Comments plugin — February 19, 2006 @ 8:49 am

  • My name is Ruby i am working on a big project at high school about blogs. I hope you don’t mind me mailing a few words on this text as my tutor needs to see it. Your blog is really good by the way.

    #40: Comment by car auction — March 9, 2006 @ 11:52 am

  • The download for this plugin doesn’t seem te work.


    #41: Comment by Niels Koops — June 24, 2006 @ 4:53 am

  • nice plugin for my blog, thanks for work, more plugins for wordpress here : Word press

    #42: Comment by Bob's Wordpress Themes — June 25, 2006 @ 9:55 pm

  • thank you for your blog, it’s interesting

    #43: Comment by google adwords ebooks — June 27, 2006 @ 3:44 pm

  • The necessary plugin (:
    It is established easily and perfectly works.
    Thank u so much!

    #44: Comment by Jimy — July 26, 2006 @ 12:44 am

  • hi there
    is there any way of using this plugin in Admin section in combination with “Paged Comment Editing” where one can have overview of all comments at once.

    I was thinking to list all the comments and give a differenct background to unread comments.

    is this possible?

    #45: Comment by kishmish — July 30, 2006 @ 9:32 pm

  • [...] Por cierto, como novedad he instalado un plugin con el que seguir los comentarios que se van registrando. Conseguir que la conversación no se pierda (”como lágrimas en la lluvia”) es una de las cosas a las que más tiempo llevo dando vueltas y creo que esto es un acercamiento bastante interesante. [...]

    #46: Pingback by Del papel a la pantalla | Sólo otro blog infame — August 21, 2006 @ 6:56 am

  • [...] Smart Unread Comments: Permite, mediante el uso de cookies, mostrar al usuario una lista de los comentarios escritos desde su última visita. [...]

    #47: Pingback by Los Blog’s de la pagina de UiDoS » Plugins para WordPress — December 24, 2006 @ 3:54 am

  • [...] like to thank Brett Taylor, as I based this plugin on his Smart Unread Comments plugin, and Show Unread Comments wouldn’t be nearly as good without using his plugin as a [...]

    #48: Pingback by Show Unread Comments - New Wordpress Plugin » The Real Ryan J. Parker — March 10, 2007 @ 8:17 am

  • [...] Smart Unread Comments: Permite, mediante el uso de cookies, mostrar al usuario una lista de los comentarios escritos desde su última visita. [...]

    #49: Pingback by Profesor Blog » Los Mejores Plugins Para Worpress — April 14, 2007 @ 10:54 pm

  • [...] cookie. Users can also mark all comments as read. Change Log: 2 entries Author: Brett Taylor Plugin Page Attached [...]

    #50: Pingback by Smart Unread Comments - DevelopeNet.com — April 16, 2007 @ 9:37 pm

  • [...] Visit [...]

    #51: Pingback by WP Plugins DB » Blog Archive » Smart Unread Comments — May 20, 2007 @ 7:33 pm

  • [...] pourquoi je le met entre guillemette, car je trouve le terme francophone assez laid merci) nommé Smart Unread Comments, qui permet à l’aide de cookie de voir les commentaires non lus. Cela est spécifique à [...]

    #52: Pingback by Dans ma tête » Smart Unread Comments — June 15, 2007 @ 3:56 am

  • [...] Smart Unread Comments [...]

    #53: Pingback by A Food Year » Blog Archive » Links! — July 7, 2007 @ 3:41 pm

  • [...] Smart Unread Comments: Permite, mediante el uso de cookies, mostrar al usuario una lista de los comentarios escritos desde su última visita. [...]

    #54: Pingback by » Enchula tu Blog,Plugins Para Worpress Información Tecnología Internet y Gadgets — July 14, 2007 @ 4:21 pm

  • [...] came across this last night and thought it was definitely worth sharing with you [...]

    #55: Pingback by Womens Discount Perfume » Not perfume but still interesting… — October 31, 2007 @ 10:01 am

  • WordPress: 2.3.3
    MySQL: 5.0.45-community-nt
    PHP: 4.4.7
    Server: Microsoft-IIS/6.0

    Plugin works fine for me. I’m curious to know how you’re using class/styling. The spacing between the line items is too much for my design, and the little li bullets are missing. Anyway I can adjust that for a better fit?

    #56: Comment by Weathervane — March 27, 2008 @ 5:56 am

  • [...] Smart Unread Comments: Permite, mediante el uso de cookies, mostrar al usuario una lista de los comentarios escritos desde su última visita. [...]

    #57: Pingback by Plugins para Wordpress. | Puydi Publicidad 100% efectiva — February 28, 2009 @ 10:30 am

  • [...] Smart Unread Comments: Permite, mediante el uso de cookies, mostrar al usuario una lista de los comentarios escritos desde su última visita. [...]

    #58: Pingback by webmaster esmuy.com » Blog Archive » Plugins para Wordpress — May 22, 2009 @ 3:30 am

  • WordPress 3.0 seems to have killed this plugin. Any chance you can take a look at it and, hopefully, it will just need a small fix? :D

    #59: Comment by Jennifer Kesler — June 19, 2010 @ 7:58 am

  • Could you update this to work with WP 3.0?

    #60: Comment by Shelly — June 20, 2010 @ 4:48 am

  • Any word on if this plugin will work with 3.0.4?

    It continually says “No New Comments”.

    Was working fine before upgrade.

    #61: Comment by Cory Fechner — January 4, 2011 @ 3:38 pm

  • Found a fix to this plugin.. Now works in 3.0 +


    #62: Comment by Cory Fechner — January 4, 2011 @ 4:12 pm

RSS feed for comments on this post. TrackBack URL

Sorry, the comment form is closed at this time.