Threaded comments were introduced in WordPress 2.7 and require activation from within the WordPress admin interface, under Settings → Discussion. Any theme that uses the proper template tag for listing the comments, which is wp_list_comments(), supports threaded comments should you want them. See the “Soapboxing: comments.php” section of “A Closer Look at Notes Blog Core” earlier in this article for more on how the actual comment output code looks. If you activate threaded comments you’ll get a reply link at the end of each comment. Clicking it will alter the post comment section somewhat and add a Cancel Reply link as well. This is all builtin stuff, so you needn’t worry about it. What you do need to consider, however, is the following:
Replies to comments end up within that particular comment’s li, inside a ul with the class children. The comment hierarchy is basically like this (lots of stuffcut out to illustrate the point):
<li> [The top level comment content] <ul class="children"> <li> [First level reply] <ul class="children"> <li> [Second level reply] </li> </ul> </li> </ul> </li> <li> [Next comment on the top level] </li>
How many ul's with the children class are allowed is determined by the threaded comment depth setting in admin. Five is the default, so your themes should support that many at least. The whole concept of threaded comments is built on hierarchy, so you should probably set the margin or padding for the children class to 10 pixels or so. It all depends on your theme, but you should make every reply indent a bit.
Styling the Reply link is easier. The link resides in a div with the class reply, so just style that any way you want. You can make it float to the right and in a font size of 12 pixels easily enough by adding this to the stylesheet:
div.reply { float:right; font-size: 12px; }
The same applies to the Cancel link that is output just below the Post a Comment header in the Respond section of the comment area. Again, this all depends on how your comments.php template looks, of course, but usually you’ll find it here. It is in a div with the cancel-comment-reply class by default. You can make that bold just as easy as you managed the Reply link:
div.cancel-comment-reply { font-weight:bold; }
If you want this link somewhere particular, you can control it by placing the cancel_comment_ reply_link() template tag wherever is suitable for your theme. Naturally, it should be close to the respond form, since that is where the link will be output. The default div listed above needs to be in the template too, so this is what you’ll be moving around:
<div class="cancel-comment-reply"> <?php cancel_comment_reply_link(); ?> </div>
Threaded comments are a great way to make longer conversations more manageable, so do consider using them if the topics on the site in question spark debates.
Our website is not responsible for the information contained by this article. Webworldarticles.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.
This article was sent to us by:
Gary Drumer at
05172010
1. Wordpress Plugins and Functions PHP
All articles in this directory are property of their respective authors. Additionally, read our Privacy Policy
© 2010 WebWorldarticles.com - All Rights Reserved.