Unreplied Comments in WordPress

Dealing with comments. What a mess! I’ve been quite busy lately so I hadn’t had too much time to reply to each and every comment on my blog, but I’d really love too, seriously! The problem however is that there were times when I replied to somebody, and times when I hadn’t and now with this mess in my comments admin it’s impossible to find out ones I haven’t replied to.

Comments: Such a mess!

I was looking for a plugin but haven’t found anything good enough. Even hosted commenting services like Disqus and Livefyre seem to lack that. Ideally I’d like to work with comments like with e-mail — read them, mark as unread, flag, assign to somebody, etc. So I quickly drafted an SQL query that gave me a list of IDs of comments that have not been replied to excluding my own:

SELECT t1.comment_ID FROM wp_comments AS t1
    LEFT JOIN wp_comments AS t2 ON t2.comment_parent = t1.comment_ID
    WHERE t2.comment_ID IS NULL
    AND t1.user_id = 0
    AND (t1.comment_approved = '0' OR t1.comment_approved = '1')
    ORDER BY t1.comment_date_gmt;

I was shocked by the amount of rows it returned so I switched the “disable commenting on posts older than 14 days” checkbox to make sure that doesn’t happen again. You can always reach me on Twitter or e-mail, right? ;)

I’d love to see this as a beginning for a new WordPress plugin that would implement some goodies for handling comments, or maybe as a tip to the hosted commenting services to create new features. In any case, I’m now stuck with over a thousand comments I have to go through.

Threaded Comments in WordPress 2.7

This was pretty quick and easy, really, you don’t even have to do much code, it’s more about styling the nested comments. First of all you have to switch them on in Settings – Discussion, then some slight theme modifications in header.php and the comments.php section. I don’t want to write about them here because it’s already written in the WordPress codex over here: Enhanced Comment Display.

Make sure you don’t skip the javascript modifications section, though I managed to get threded comments without it, but javascript makes it alive. It’s the code that is responsible for putting the reply form just below the comment you want to reply to on the fly, i.e. without having to reload and render a new page.

Now use Firebug to create and modify CSS on the comments page – just use your imagination and make it look good. The issues I had are:

  • The textarea box was ~700px wide and it overlayed my sidebar when I tried to reply to someone. Changed that to 100% – looks good now
  • The comments and replies are actually different elements. The comments are OL (ordered list) and the replies are UL (unordered list). The UL with the classname ‘children’ should have the margin-left, don’t mess that up.
  • Threded comments can be lost without borders. I don’t really like how they look in the default theme, but my variant is a little bit of padding-left and border-left for the UL/OL commentlist/children LI elements.
  • The ‘Reply’ anchor is not part of the comment and is not within the P tags, so I had to margin-left that separately.
  • The comment form in a reply needs a margin-left, but doesn’t when you’re starting the thread. You can use something similar to this (.comment indicates that it’s a reply and #respond is the actual form):
    .comment #respond { margin-left: 42px; }
    

I guess that’s it. Questions and suggestions are welcome in the comments.

Removing Comments Author Links

Askimet (the anti-spam plugin for wordpress) is great, but when it comes to readers commenting posts and leaving backlinks to their sites, Askimet doesn’t count that as spam unless the message doesn’t look like one. Yeah, wordpress marks them with a ‘nofollow’ attribute, but search engines aren’t the worst case in this situation. It’s pretty good if readers leave backlinks to sites that are more or less relevant to yours, but what if it’s something about travel and hotel bookings? That would piss me off…

You can manually edit the comments and remove backlinks, but you’ll get annoyed doing that with ~100 comments per day. Anyways, here’s a quick tip of how to remove all author links forever.

Go to your wordpress admin panel, pick the ‘design’ section and click ‘theme editor’. Now, in the list on the right you’ll see some files related to the current theme. You’ll have to find the one that’s ‘driving’ comments. This can vary from theme to theme, but most likely it will be called comments.php.

Then find something similar to:

<?php comment_author_link() ?>

And replace it with:

<?php comment_author() ?>

Voila! And no more author links in comments ;) Good luck!