Show Unread Comments WordPress Plugin
Welcome to the homepage for my Show Unread Comments WordPress plugin. Everything you need to know about the plugin is on this page, but if you’ve still got a question then visit my contact page to get in touch with me.
Latest Version: 1.1
Subscribe now to get notified when this plugin is updated.
What does Show Unread Comments do?
This plugin keeps track of your reader’s unread comments to show an appropriate status indicator next to read and unread comments. This plugin also provides the ability to show a list of posts with unread comments.
| Unread Comment Indicator |
Read Comment Indicator |
|---|---|
![]() |
![]() |
Installing Show Unread Comments
To install the Show Unread Comments WordPress plugin you’ll first need to download the plugin:
Format: ZIP; Size: 6.0KB
Extract the contents of this archive into your wp-content/plugins directory. It is very important that the archive hierarchy remains the same when you extract the archive. You can ensure this by making sure all archive files are in the wp-content/plugins/show-unread-comments directory.
Now you must go to the Plugins page of your WordPress administration interface and activate the Show Unread Comments plugin. As soon as the plugin is activated the read/unread status of all comments will begin being tracked.
Upgrading Show Unread Comments
If you’re upgrading to a new version of the plugin, simply follow the installation instructions above and you’ll be set. As long as you extract the archive into the appropriate directory you’ll be done with the upgrade.
Integrating Comment Status Indicators
To integrate the comment status indicators you’ll need to edit your template’s comments.php file and add the following code to the comments loop:
<?php show_unread_comment_status(); ?>To provide full customization, this code only outputs the comment’s read/unread status. You can wrap this code inside of a <div> tag to customize the placement of the indicator. On my blog I use the following code to float the indicator to the right of each comment:
<div style='float: right;'>
<?php show_unread_comment_status(); ?></div>Note: I place this code directly after the <li> tag that begins each comment in the comments loop.
Customizing show_unread_comment_status()
The show_unread_comment_status() function accepts three parameters that you can use to customize the look of the read/unread status indicators:
show_unread_comment_status($type, $img_read, $img_unread)- $type: Specifies the type of status indicator to show.
Values: image (default), text, and bin
If you specify image for $type then the function will use the $img_read and $img_unread images as the status indicators.
If you specify text for $type then the function will show READ and UNREAD text as the status indicators.
If you specify bin for $type then the function will return true if the comment has been read and false if the comment is unread.
- $img_read: Specifies the read status image.*
- $img_unread: Specifies the unread status image.*
*Note: You must place status indicator image files in the directory:
Example: To specify your own read and unread images use code similar to the following:
show_unread_comment_status('image','read.jpg','unread.jpg');Customization via CSS
You can also customize the image status indicators via the style.css file included with the plugin. The default stylesheet specifies a small border around each image, but you can modify this file to customize the images as you see fit. The class names are suc_read and suc_unread if you wish to override them in another CSS file.
Listing Unread Comments
To show a list of unread comments from the last 14 days in the sidebar of your blog you’ll need to edit your template’s sidebar.php file and add the following code where you want the list of unread comments to be displayed:
<?php echo show_unread_comments(); ?>Adding this code will only show the list of unread comments, so make sure you enclose this code between your template’s appropriate <li> and <ul> tags.
Customizing show_unread_comments()
The show_unread_comments() function accepts five parameters that you can use to customize the unread comments list:
show_unread_comments($limit, $sort, $output_when_none, $mark_as_read_text, $no_unread_text)- $limit: Specifies the maximum number of posts with unread comments to list.
Values: A number at least 1. Default: 5
- $sort: Specifies how to sort the unread comments list.
Values: comment (default) and post.
If you specify comment for $sort the list is sorted by comment date.
If you specify post for $sort the list is sorted by the post date.
- $output_when_none: A boolean (true/false) parameter that, if true, specifies that the plugin show $no_unread_text when there are no unread comments. Default: true
- $mark_as_read_text: Specifies the text of the link to mark all comments as read.
- $no_unread_text: Specifies the text shown when there are no unread comments.
Known Issues
None! If you find an issue with the plugin please comment below or contact me.
Credit
This plugin is derived from Brett Taylor’s Smart Unread Comments plugin, so if it weren’t for using his code as a starting point this plugin probably wouldn’t be nearly as good.
More
If you’ve got a suggestion or comment please provide feedback using the comments section below or visit my contact page to get in touch with me.
Also, if you haven’t done so already, subscribe now to get notified when this plugin is updated.
Version History
- 1.1: Plugin now keeps track of unread comments on pages. Updated
show_unread_comment_status()to add an option to return a binary value for dynamically updating comment CSS classes. - 1.0: Initial release



60 Comments so far »
noname said
on March 9 2007 @ 4:30 pm
Wonderfull - this is exactly what I was looking for and what I was missing a lot, thx
Emre Safak said
on March 10 2007 @ 10:03 am
How can you embed a link to skip to the first unread comment?
Ryan J. Parker said
on March 10 2007 @ 10:09 am
Emre, if you click the number of unread comments between the () next to each post with unread comments you will be taken directly to the oldest unread comment.
I’m not exactly sure what you’re wanting to do, but if you wanted to you could modify the show-unread-comments.php file and edit line 249 and make it so that the link to the post is the link to the oldest unread comment.
Hope that helps.
Emre Safak said
on March 10 2007 @ 10:14 am
Another request: make the function return a binary variable so we can use it to change the underlying CSS, rather than embedding an image. For example, I could use a different style attribute for DIVs with new comments.
Please add your plug-in to wp-plugins.net. This way, people like me who use Update Manager (http://www.mutube.com/projects/wordpress/update-manager/) will be able to easily keep track of updates.
Ryan J. Parker said
on March 10 2007 @ 10:19 am
Emre, would you like a function that just prints a link to the first unread comment?
Also, that’s a great idea about the binary return for updating the CSS.
The plugin is already on wp-plugins.net: http://wp-plugins.net/plugin/show-unread-comments/#plugin_2279
I want to fix the keeping track of comments on pages, too, so I can add these other two things in fairly easily.
Emre Safak said
on March 10 2007 @ 10:49 am
Yes, I just want a clear link at the top of the comments to take the reader to the first unread comment. Really, this is what people want to do.
[a href=”get_first_unread_comment()”]Skip to first unread comment[/a]
Ryan J. Parker said
on March 10 2007 @ 11:03 am
Emre, thanks for the feedback.
I agree, that’d be great for people that click the ‘comments’ link and then want to jump directly to the oldest unread comment. I’ll add this in, too.
Did you find the plugin on wp-plugins.net?
Emre Safak said
on March 10 2007 @ 11:12 am
It is not showing up in my Update Manager. Maybe that is because I have the most recent version? We will know for sure when you implement the changes we have discussed.
David said
on March 11 2007 @ 12:25 am
Great work for this plugin. I’m definitely interested in incorporating it into my website. I was wondering, however, can this work with pop-up comments because that’s what I have set up.
Ryan J. Parker said
on March 12 2007 @ 4:43 pm
David, this plugin should be fine with popup comments. The plugin writes out a cookie whenever the user views the post. I am, however, interested in hearing if it works for you.
noname said
on March 15 2007 @ 7:44 pm
i was thinking about this plugin again but I probably found a problem - i use cache (wp cache plugin), and because you store and test the information on the php side, it will not work (it will show read/unread for someone else). Maybe it will be better to use javascript, local cookie with last visited date, and then mark unread the newer.
P.S.: BTW i think it would be much better to just put some class to the comment div, and then you can do anything just by styles e.g.
.comment.read {
display: none;
}
etc
Ryan J. Parker said
on March 15 2007 @ 7:53 pm
noname, the plugin uses cookies to keep track of read/unread comments. It uses the PHP to send out the cookie. I’m not all that familiar with wp cache, but all of the the information is already stored on the client.
Also, based on Emre’s suggestion, I’m going to implement a binary function so that you can create your own unread/read classes (as you mention) so that you can style them as you see fit.
dave said
on March 15 2007 @ 8:07 pm
Love the plugin. What I would really like to do is be able to hide all read comments. I use Brian’s threaded comments plugin and it allows me to collapse any comment I want. If I could collapse all the read comments it would make my list much shorter and easier to navigate. I’m thinking if the show_unread_comment_status() returned either true or false, then I could change my css to hide unread or at least collapse them.
dave said
on March 15 2007 @ 8:10 pm
oops just realized you answered my question before I asked
Or maybe as I was asking
Gary Lee said
on March 17 2007 @ 12:35 pm
wow . . interesting plugin that shows that nothing’s safe on the net! hahaha
Ryan J. Parker said
on March 17 2007 @ 1:07 pm
Gary, this plugin doesn’t violate your reader’s privacy.
dave said
on March 17 2007 @ 11:09 pm
Thanks for the binary update. I had actually made the change to the plug-in already but I’ll download yours. Another change I made was to allow the “READ” or “UNREAD” text to be configured the same way the images are chosen.
Ryan J. Parker said
on March 19 2007 @ 12:24 am
dave, that’s a good idea, too. I thought about it but wasn’t sure if anyone would even be using the text.
Did you make it so that the second and third parameters will change based on the $type that is passed? This is something I’ll add into the next version.
Jim said
on March 26 2007 @ 11:00 am
Very nice plugin! Another one that may become a staple on all my WP installations.
Manne said
on April 2 2007 @ 4:55 pm
Hi, this seems to be a very nice plugin. I was wondering if it could be modified to show unread posts instead?
Ryan J. Parker said
on April 11 2007 @ 12:45 pm
Manne, that’s a pretty good idea. I think I’ll put together a show unread posts plugin. I’ll want to check and make sure it’s not already out there, of course.
Manne said
on April 12 2007 @ 12:10 pm
Great Ryan!
I know about the “Since Last Visit” plugin (http://alexking.org/projects/wordpress) put I don’t think it works for WP 2.X (at least not for me).
For me, it would be great if such a plugin could show new posts since last login for registered users, and/or posts that remain unread.
Danny said
on April 18 2007 @ 1:24 pm
I’d like to second the request for a version of this for posts. I’ve been struggling with Alex King’s plugin for a while, trying to make it work, but I have failed.
Please consider releasing something like this for posts, or a combined one for posts and comments. Thank you.
Mark said
on April 30 2007 @ 5:37 pm
I am having a problem getting a ’show last comments’ to display on a sidebar widget, when I place the code in a text widget.
It works if I place the code outside the sidebar widget loop.
TechZilo said
on June 3 2007 @ 3:28 am
Nice plugin, I am gonna try it.
You got a lions share of traffic from it, so why no more plugins?
Tyler said
on July 28 2007 @ 1:28 am
I third the notion of making a version for both posts and comments. It would mighty useful as Alex Kings’s plugin doesn’t want to work for me.
Thanks!
Tyler
Martin said
on August 24 2007 @ 1:26 pm
Quick question. I just implemented the plugin and have comments as far back as May 07. All comments are showing as new. After reading comments within 14 days the new symbol changes to read symbol, which is fine, but all comments older than 14 days do not get set to read and keep showing up as new each time you visit. Anything that can be group patched quickly to show all comments older than 14 days as read?
manele said
on August 31 2007 @ 5:41 am
thank you for your plugin. i use it on my blog…is pretty cool
Laarni said
on September 3 2007 @ 9:39 am
Very helpful. Thank you.
Martin said
on September 8 2007 @ 5:55 pm
Cancel request for help on flagging comments older than 14 days as read… Got it!
Alfons said
on September 19 2007 @ 1:57 pm
Your plugin in great, but it would be even better if there would be a widget for the comment list.
MJ Klein said
on October 27 2007 @ 11:48 pm
as dumb as this sounds, i’m using the Prosumer theme and it’s totally different from your example using the default theme. i have no idea where to put the code to make this plug-in work. the name of the file is wp-comments-post.php in this theme. sorry but i’m not a programmer
Martin said
on October 28 2007 @ 5:08 pm
Hello MJ:
I don’t use the Prosumer theme, but downloaded it just to see how it looked. I believe you can place the line of code just about anywhere you want to see the symbol. On the Prosumer theme, placing the first example shown right after the line in the comments.php file where you see the tesxt “Says:” (around line 47) will place the read/unread symbol right after the text “Says:”. (See following code) Of course if you want to float the indicator, you need to use the second example by the author. Hope this helps.
Says:
comment_approved == ‘0′) : ?>
Martin said
on October 28 2007 @ 5:13 pm
Sorry, it looks like the comments don’t like code being inserted.. I will try again removing the php part:
Says:
show_unread_comment_status()
if ($comment->comment_approved == ‘0′) :
MJ Klein said
on November 6 2007 @ 10:29 pm
thanks Martin, i’m going to try to install now.
MJ Klein said
on November 6 2007 @ 10:46 pm
Says:
show_unread_comment_status()
if ($comment->comment_approved == ‘0′) :
didn’t work for me. the output was the text of the code. i’ll keep trying to figure it out. thanks for your help Martin.
MJ Klein said
on November 6 2007 @ 10:48 pm
got it! sorry for the multi messages.
Martin said
on November 8 2007 @ 12:07 am
Glad you finally got it worked out. It would be nice if some of the code weren’t stripped out when making comments. I believe there is something that you can enclose the code with so that it appears in this comment as is, but will have to search for that again.
BTW, I like the looks of the Prosumer theme and just might use it as one of my themes.
Li-An said
on June 29 2008 @ 10:34 am
I don’t understand how to use the values. Can I have one example please ?
Ryan J. Parker said
on June 29 2008 @ 6:42 pm
Li-An, what values are you referring to?
Li-An said
on June 30 2008 @ 3:45 am
In show_unread_comment_status($type, $img_read, $img_unread)
how to give a value to $type ? $type = 5?
Comment RSS · TrackBack URI
Leave a comment
Pingbacks/Trackbacks
Pingback on March 9 2007 @ 3:17 pm
Pingback on March 9 2007 @ 11:51 pm
Pingback on March 10 2007 @ 10:20 am
Pingback on March 11 2007 @ 11:18 am
Pingback on March 12 2007 @ 1:40 am
Pingback on March 13 2007 @ 1:23 am
Pingback on March 16 2007 @ 6:31 am
Pingback on March 24 2007 @ 3:05 am
Pingback on March 25 2007 @ 9:13 am
Pingback on March 25 2007 @ 10:37 am
Pingback on March 31 2007 @ 9:04 am
Pingback on April 3 2007 @ 5:34 am
Pingback on April 5 2007 @ 2:13 pm
Pingback on April 16 2007 @ 5:33 am
Pingback on April 21 2007 @ 10:39 am
Pingback on July 6 2007 @ 11:41 pm
Pingback on July 12 2007 @ 1:46 am
Trackback on July 23 2007 @ 7:49 am
Pingback on August 9 2007 @ 1:13 pm