Howdy! Thanks for coming and enjoy your stay! Take a look at the sitemap and don't forget to chirp!

Threaded Comments in WordPress 2.7

February 19th, 2009

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.

The Ability to Reply ... to a Reply

The Ability to Reply ... to a Reply

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.

Related posts:

  1. WordPress: Recent Comments by Category
  2. Removing Comments Author Links
  3. Javascript in WordPress: 2 Functions 2 Save Your Day
  4. WordPress: Extending the Contact Form 7 Plugin
  5. WordPress: Theme Design Tips & Tricks

9 Responses to “Threaded Comments in WordPress 2.7”

  1. wow your posts are really great, totally focused on topic. Mine are always all over the place!
    Lots of great information here, I’m going to have to make a blogroll and put you on it.
    Great work!

    • kovshenin (@kovshenin)

      Oh, that would be sweet! Thanks :) Glad you liked it.

      • test it

        • kovshenin (@kovshenin)

          Thank you :) and thanks for testing ;)

        • swift

          testing

  2. looks good

  3. Great.. looks good, I have started using it already!

    • kovshenin (@kovshenin)

      Thanks. I see, yeah looks cool. Well done!

      • Now I can follow all comments and comment back easy way!

        I love the emailing system of this plugin.

Including pingbacks & trackbacks

  1. You can be the first!