WordPress Tip: Implement WordPress's Threaded Comments
WordPress's threaded comments feature is not entirely now; it's been around since 2.7 (the current version of WordPress is 2.7.1). But even though under Settings > Discussion you see the ability to activate threaded comments and indicate how many levels deep you want it to be, you have to actually make some changes to your theme for threaded comments to work.
The following screenshot shows an example of threaded comments.
You see that you can reply to comments directly within the thread, rather than at the bottom. If you receive a lot of comments, threaded comments can add a lot to the usability of the conversation.
Implementing Threaded Comments
To implement threaded comments in WordPress:
- Go to Settings > Discussion and select Enable threaded (nested) comments X levels deep. (I chose 3 levels deep only.)
- Make sure your theme doesn't already have threaded comments. Navigate to a post with a comment. If your theme already has threaded comments, you'll see a Reply link next to each comment. If not, continue following the steps below.
- Make sure you've upgraded to the latest version of WordPress (2.7 at least).
- In your header.php file, add if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); directly before wp_head, so that it looks like this:
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); wp_head(); ?> - Download the latest release from WordPress, unzip the file, and browse to wp-content/themes/default. Open the default theme's comments.php file and copy the contents.
- Back up your existing theme's comments.php file in case something goes wrong.
- Navigate to Appearance > Editor and select Comments.php. Paste in the comments.php content you copied in step 5. Save the update.
- Navigate to a post with comments and see if the Reply link appears next to the individual comment. If so, you implemented it correctly.
Styling Threaded Comments
Now, you're not done. When I looked at my threaded comments, my comment form spilled over the margins, and the nested comments appeared in the same white color, making them harder to distinguish from the upper level. Your theme was probably designed before threaded comments were launched, so you have to add some code to your stylesheet to make the threaded comments look good.
Here is what I added to my stylesheet to style my threaded comments:
#comment {width:525px; padding:10px;}
.commentlist li ul li {background-color: #f3f2f1; border:1px solid #e5e4e2; padding-bottom:10px; margin-bottom:10px; margin-top:13px;}
.commentlist li ul li ul li {background-color: white;}
Depending on your theme, you may need to add different code. Someone else has a lot more style they added to their theme. If you're trying to style the threaded comments list, this support post may be helpful. (Note: I wasn't able to get bulleted and numbered lists to look right in comments at all levels, but given that almost no one manually codes bulleted or numbered lists in comments, I doubt it will be much of a problem.)
Threaded Comments Plugins
If you don't want to change your theme, you can rely on a number of threaded comments plugins instead:
- Brian's Threaded Comments
- Yet Another Threaded Comments plugin
- Greg's Threaded Comments
- WordPress Threaded Comments (this is what's implemented on Jane's blog right now)
Finally, here's more technical information about the threaded comments function. Remember that I also offer WordPress Consulting services, so if you're trying to get threaded comments to appear on your theme and you have trouble, let me know.
About Tom Johnson
I'm an API technical writer based in the Seattle area. On this blog, I write about topics related to technical writing and communication — such as software documentation, API documentation, AI, information architecture, content strategy, writing processes, plain language, tech comm careers, and more. Check out my API documentation course if you're looking for more info about documenting APIs. Or see my posts on AI and AI course section for more on the latest in AI and tech comm.
If you're a technical writer and want to keep on top of the latest trends in the tech comm, be sure to subscribe to email updates below. You can also learn more about me or contact me. Finally, note that the opinions I express on my blog are my own points of view, not that of my employer.