WordPress 2.7 Comments Enhancements

This post has been moved here: http://ottopress.com/2008/wordpress-2-7-comments-enhancements/

WordPress 2.7 includes a lot of new enhancements, but one of the big ones is the new comment functionality. Comments can be threaded, paged, etc. This is all built in, but unfortunately, your theme must support it. So, for theme authors, I’d suggest getting to work on making your themes compatible right away.

Read on if you’re a theme author…

Note: A lot of people seem to miss this key bit: Enhanced Comments are optional and default to off, even after you make these changes. You have to go to the Settings->Discussion panel to turn the features on.

Actually “compatible” is not quite the right term. Old themes will continue to work fine in WordPress 2.7. It’s just the threading and paging and javascript enhancements need the theme to support it. This is much the same as the sidebar widgets, the theme has to support it for the functionality to work. So this article is really not about 2.7 compatibility, it’s about 2.7 capability.

Note that this article will explain some of the changes needed to make themes capable of supporting the new comments functions, however there’s no substitute for the real thing. Install a local copy of WordPress trunk on your home machine (possibly using XAMPP) and test it there.

Also note that this is all based on the current state of WordPress trunk, and is subject to change before WordPress 2.7 is released. However, it’s probably not going to change all that much at this point.

How to create a 2.7 compatible comments.php

2.7 Detection

If you want your theme to be backward compatible as well, then there’s a simple way to do it. Just check for the wp_list_comments function, like so:

if (function_exists('wp_list_comments')) :
// new comments.php stuff
else :
// old comments.php stuff
endif;

While you could check for the version number of WordPress, this method is better because it simply looks for the actual function you’re going to use anyway. Never make assumptions based on version number.

One of the more interesting ways I’ve seen to use this is to have the “old comments” php in a separate file entirely, which is then included. This preserves backwards compatibility for your theme in a simple way. Here’s a quick example code for that approach:

<?php
add_filter('comments_template', 'legacy_comments');
function legacy_comments($file) {
	if ( !function_exists('wp_list_comments') )
		$file = TEMPLATEPATH . '/legacy.comments.php';
	return $file;
}
?>

Adding this code to a theme’s functions.php file will make the theme use the “legacy.comments.php” for older non-2.7 installations. That way, you can simply rename your old comments.php and then make a new one based on the new functionality. Clever.

Password Protection Check

Put this code at the top of your comments.php file. This is what lets it support the post password functionality. Note that this code is quite similar to the previous way that it was done (by checking the cookie directly), but now WordPress has a specific function to do it. You should use this function in case the functionality changes in the future, your code will be forward compatible:

if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
	die ('Please do not load this page directly. Thanks!');
if ( post_password_required() ) {
	echo 'This post is password protected. Enter the password to view comments.';
	return;
}
<h4>The Comments Loop</h4>
The Comments Loop used to look similar to this (much simplified from a real one):
[php]if ($comments) :
<?php $comment_count = get_comment_count($post->ID); echo $comment_count['approved']; ?> Comments
<ul class="commentlist">
<?php foreach( $comments as $comment ) :
// stuff to display the comment in an LI here
endforeach;
?></ul>
<?php else :
if ('open' == $post-comment_status) :
	// If comments are open, but there are no comments.
else :
	// comments are closed
endif;
endif;

Basically, it went through the comments manually and output all the necessary pieces. Easy, but very manual. This also had the problem of being very inconsistent and hard to manage for your theme’s users, especially if you heavily customized it.

The new comments loop is much simpler:

<?php if ( have_comments() ) : ?>
<h4 id="comments"><?php comments_number('No Comments', 'One Comment', '% Comments' );?></h4>

<ul class="commentlist">
<?php wp_list_comments(); ?>
</ul>

<div class="navigation">
<div class="alignleft">< ?php previous_comments_link() ?></div>
<div class="alignright">< ?php next_comments_link() ?></div>
</div>
<?php else : // this is displayed if there are no comments so far ?>
	<?php if ('open' == $post->comment_status) :
		// If comments are open, but there are no comments.
	else : // comments are closed
	endif;
endif;
?>

That new one is, in fact, a complete comments loop. No simplification at all. Unless you want something displayed for “no comments” or “comments closed”, of course. I don’t have anything showing there.

There are three important pieces to note here:

  • The have_comments() function replaces the check on the global $comments variable.
  • The wp_list_comments() function now outputs all the comments. It does threading, the classes, everything new.
  • There’s a new navigation section to do comment paging.

The Power of Javascript

To support the new Javascript functionality with comment threading, some minor bits of code are needed:

First, in the header.php, add this line immediately before the call to wp_head():

if ( is_singular() ) wp_enqueue_script( 'comment-reply' );

That code adds the comment-reply javascript to the single post pages, letting the comment reply links work correctly. WordPress specifically does NOT do this itself, for the reason that use of this script requires certain naming conventions and parameters in the comment form, which you’ll have to add.

So, your comment form has a new parameter that you have to add:

<?php comment_id_fields(); ?>

This adds a bit of code to your form which makes it display two hidden inputs: comment_post_ID and comment_parent. Your form probably had the comment_post_ID before, so you need to remove it. The comment_parent is there for the javascript, so that replies to comments get threaded properly.

Also, your comment textarea MUST have an id=”comment”. The javascript expects it for focus purposes. If you used anything else, change it. Note that because of this, no other element on your page can have the “comment” ID.

Finally, the entire comment form MUST be surrounded by a DIV with an id=”respond”. In some previous themes (including the default ones), there would be an anchor tag like this:

<a id="respond"></a>

This was there to allow the link from the front page to go directly to the respond section when there were no comments already. That still happens, but now there’s a double purpose. The javascript moves the comment form to where the reply link is, so instead of it being an anchor, it needs to be a DIV that surrounds the comment form.

So, remove that anchor, and add a DIV with an id=”respond” around the entire comment form. The link from the front page still works this way with all modern browsers, and the javascript can now move the form around on the page as needed.

Next, you can replace the call to your normal “Leave a Comment” text with something like this:

<h3><?php comment_form_title(); ?></h3>

This makes a comment form title of “Leave a Reply” which will change to “Leave a Reply to Whoever” when somebody is replying directly to another person. You can customize this, if you like, with two parameters, like so:

<?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?>

The %s will be replaced with the person’s name. This will only happen when the javascript isn’t working and the reply links have to cause a page refresh. So it’s usually not worth customizing much. Still, not everybody runs javascript and so this is nice to let them know who they are replying to.

Finally, you’ll notice that when somebody clicks “reply” and the comment form appears there, maybe they decide to cancel instead. So, that cancel link needs to be in your respond section. Here’s the code to do that, just put it right below your “leave a message” header in the comment form area:

<div id="cancel-comment-reply">
	<small><?php cancel_comment_reply_link() ?></small></div>

That’s pretty much it for making the AJAX work. With this, the new features on the Settings->Discussion panel will work. Obviously, you can modify this somewhat as needed for your theme, these are just general principles that you’ll need to use.

Styling

Now that you have it working, there’s plenty of new styling you can add to comments. The new comments loop automatically puts every comment into an LI tag, and threads them as well, with embedded UL/LI tags. It also adds a ton of classes on all these LIs which surround every comment in this fashion:

  • comment, trackback, pingback classes get added depending on the type of the comment.
  • byuser gets added if the comment is by a registered user of the site.
  • comment-author-authorname gets added for specific registered users.
  • bypostauthor gets added if the comment is by the author of the post the comment is attached to.
  • odd and even classes are added to odd and even numbered comments
  • alt is added to every other comment
  • thread-odd, thread-even, and thread-alt classes are the same as the odd/even/alt classes, but these only apply to the top level of each set of comments and replies
  • depth-1 is added to the top level comments, depth-2 to the next level, and so on.

What’s more, a comment_class filter is provided to allow you to add your own classes. Here’s an example of that. This example function adds a microid to every comment with the microid for the comment authors given URL and email address. This sort of thing could be done in a plugin or a theme’s functions.php file, whatever.

// add a microid to all the comments
function comment_add_microid($classes) {
	$c_email=get_comment_author_email();
	$c_url=get_comment_author_url();
	if (!empty($c_email) && !empty($c_url)) {
		$microid = 'microid-mailto+http:sha1:' . sha1(sha1('mailto:'.$c_email).sha1($c_url));
		$classes[] = $microid;
	}
	return $classes;
}
add_filter('comment_class','comment_add_microid');

Simple and effective. It just adds the class to the given array of classes and lets the comment display functions take care of the rest.

And there you have it. It’s not hard to support the new functions. And if you need to customize your theme’s comments section even more, wp_list_comments() supports a number of parameters. Most of this is not documented yet, because WordPress 2.7 is not out until November. However, the code is relatively straightforward, and anybody with a good understanding of WordPress should be able to work it out.

Additional: A lot of people keep asking me for a full-fledged example. Really, I recommend that you examine the comments.php file in the default theme in the 2.7 beta versions. However, the actual comments.php file I’m using on this site can be found here: http://ottodestruct.com/comments.phps, if it helps you any. It has the code I’ve described in this article, pretty much verbatim. The only additions to it are a couple of extra options on the wp_list_comments() call, such as avatar_size and reply_text.

403 thoughts on “WordPress 2.7 Comments Enhancements”

    1. I haven’t done a lot of styling yet, but you can at least see some of it here, what with the threading and my comments being a bit more blue than yours (thanks to the bypostauthor class).

          1. Define “tacky”, exactly? If you’re talking about the style, then that’s entirely up to you. I made my comments a bit tacky to sort of demonstrate how it works. I was not too concerned with style. πŸ™‚

            But yes, even with the new comments functionality, there’s several options on the Settings->Discussion page. You can enable/disable threading, put a limit on how deep the comments can thread, number per page, choose the ordering (newest first, oldest first), etc, etc…

            But none of those options work until your theme supports them like this article describes.

        1. I ask to forgive my poor English – I live in Ukraine, I use the program-compiler: (

          At me all has turned out, except one – comments turn out NOT threaded though the necessary point in options WP is noted.

          And it just what I try to achieve from comments in a blog http://allpa.ru/- what to do? How to rectify situation?
          Very much I hope for your help…

          It would be desirable to allocate still comments of the author of a blog with other colour how it is made at you – you could not prompt the necessary actions?

          Thanks!:)

  1. Wow, you guys did a lot of work, hopefully all the themers will take advantage of all these new features for comments. I’m guessing all of the code you mentioned here is build into the default theme right?

    1. Yes, the default theme uses this new functionality and shows this stuff off fairly effectively. The old theme comment methods will still actually work, however the new functionality (thread, paging, AJAX, etc) won’t work until the theme is modified to do it this way.

      Here’s the trac ticket where all these enhancements were added along with who added them: http://trac.wordpress.org/ticket/7635

  2. Just one little nitpick: “AJAX”? Its not Ajaxified by default at all, just Javascript to move the reply form, You dont want to confuse people now do you..? πŸ˜›

    Hopefully this article will be useful to theme developers though, It can be a bit confusing at first following the default themee layouts.

    1. Bah. I suspect that it will become more AJAXified as time goes on. I can see comment replies getting put onto the page without a refresh, for example. That would be pretty cool.

  3. A sample comment file would be especially helpful for those of us who have a theme made by someone no longer available to modify. So we have to middle through.

    Also how would we deal with an existing quoting plugin and the new features?

    Explain, please, for the PHP-challenged.

    Peace,
    Gene

    1. The default theme has implemented this into it as of 2.7. I have not checked the classic theme, but it will likely get the same treatment.

      As for how you’ll deal with the plugin, well, it really depends on the plugin. This new code makes many plugins obsolete, however the old style of comments still works fine, so if you want to keep using plugins instead of the new stuff, you can.

      1. Quoter, no longer being updated, gives each quote a specific number, so only that item appears in the comment, even if it’s not the previous message.

        I wouldn’t mind this Reply function instead, and disable that plugin, but then I’d have to find a way to do a wild card search to eliminate the extra code in the blockquotes. Do any of the search and replace plugins accomplish that?

        This would be a viable solution. Our standard comments theme file is very close to the default/classic ones, with only minor changes I can, as PHP-deficient as I am fix.

        I’m not averse to removing plugins that’ll no longer be needed.

        But this is the lone issue I’ll need to consider.

        Peace,
        Gene

        1. You could probably figure out a way to script it and convert.

          If you have any way to determine which comment number the quote came from, then you can thread your comments. The comment threading works by including a comment_parent value with each comment. The contents of that column is the comment_id of the parent. So if your quoter has that, then you write a script to:
          a) remove the quote
          b) save the comment_id value of where the quote came from in the comment_parent

          And voila, threading.

  4. Thanks for the great tips.

    I would like to know if with the new features, can I still separate trackbacks from comments? And also, how do I go about making my comments threaded, or is it already integrated with the new function?

    Again, thanks for your help.

    Will
    http://will.ph/

    1. Yes, the wp_list_comments function takes a “type” parameter to get different types of comments. It defaults to “all”, but it can also be: comment, trackback, pingback, or “pings” for both trackbacks and pingbacks combined. So wp_list_comments(‘type=pings’); would give you all the pings.

      Also, as you can see, the trackback/pingbacks can be integrated but styled differently. I made them yellow here for purposes of demonstration. I need to sit down and restyle my comments sections, actually. πŸ˜‰

      Threading is handled automatically, and in the Settings->Discussion area, you can set a depth parameter, with how many levels deep you want the threading to go.

      wp_list_comments takes several arguments, which I did not go into because most themes won’t (or should not) use them. However, it is as configurable as everything else when it comes to styling and such.

  5. You said: “Also note that this is all based on the current state of WordPress trunk, and is subject to change before WordPress 2.7 is released.”

    My question is this. Is there a place that I can check before installing the 2.7 update to know how to bring my theme up to par?

    1. Non-modified themes will continue to work in WordPress 2.7 (they do now anyway). They just won’t have the new threading or paging functionality.

      So upgrading doesn’t mean making sure your theme is up to par in advance, you can fix up the theme after the fact.

  6. It took me a little while to test out, but it works great so far on my test site! I thought I would mention that you MUST set a thread level in the Discussion settings AND check the “Group replies” option. Otherwise it will default to 0 and you will not see threaded comments or reply links even if you have the “Group replies” option checked.

    1. Actually, if you leave it blank (not zero), then it defaults to -1, which is unlimited levels of threading. That should probably be clarified there somehow.

  7. Hi Otto,

    I have another question. Would the function “have_comment()” accept a parameter such as type=pings so one can easily separate comments from trackbacks/pingbacks?

    Thanks again for the tips.

      1. Hi Otto if I can separate comments from pings I’m very happy.

        Threaded comments are not my favour and if WP 2.7 comes I have less possibilities to design them,
        because css doesn’t accept 6 different styles in one class.

        how can I add divs to design the author or the meta section of comments?

        kindly regards
        Monika

        1. I’m not entirely sure what you mean by CSS not accepting styles/classes. Styling your comments is very very easy with this code.

          If you look at the code, the author data gets encapsulated inside a div with a class of comment-author. The meta data gets put inside comment-meta as well as commentmetadata. This is automatic, you don’t need to change a thing to get it.

  8. One thing I really think about WordPress 2.7: it is such a massive overhaul to so many aspects of WordPress (with a lot of potential for compatibility issues) that I think it should be called WordPress 3.0, with the 2.6 branch maintained for security fixes. I am actually very happy with how I’ve gotten Sachiko’s blog (I am her webmaster) running with 2.6 and the combination of plug-ins that we have, and I can see a lot of this will be broken in 2.7. That will probably be worth it in the long run, but I suspect it will be quite a while before I am able to upgrade.

  9. This is splendid. Thank you so much.

    BUT…if I had used one of the paged threaded comment plugins before, how will switching to a built-in facility of the same kind affect my old comments?

    1. Really depends on how the old threading plugin worked. If it used comment_parent, then the threading will persist. If not, then you’ll probably lose that threading info from the old comments.

  10. I’m really excited to see how 2.7 comes across. There have been a lot of minor issues with 2.6 that I wasn’t overly impressed with but I think if the new framework is anything to go by, this is going to be great.

  11. Oh my my… this is a hell lot of coding for a geek like me. Isn’t there any simple just one click solutions. Man… I want to try out these functions as well. but, what if anything goes wrong…

  12. Correction:
    Thanks a lot for this detailed guide. I couldn’t make it work by just following the steps above.
    I think you need to ad the following line to the comments form after the hidden field:
    comment_parent_field();

        1. The comment_parent_field function is gone now. It’s been replaced by comment_id_fields, which does both the parent field and the post id field.

      1. Done. In the latest trunk, you should be able to pass a “reply_text” argument to the wp_list_comments to set the text of the “Reply” link.

  13. Have been debating whether or not to design my own theme from scratch, as I build sites everyday at work!

    But after reviewing some of the new features of 2.7 think I might start build specifically for that.

  14. Hi Otto,
    Thanks for the how-to! I am excited about the new comment features. Particularly threaded comments. I was beginning to consider a plugin like JS-Kit until I heard about the new features.

    Excellent work!

    Byron

  15. This is lovely, I was just struggling with making the foreach loop do a bunch of these things, and now it will come integrated. This is good!

    I have a question, though. Clearly get_avatar or similar is being used inside wp_list_comments, yes? Is there (or is there going to be) a way for plugins to override that function? Because all the alternate-avatar plugins I’ve seen rely on manually inserting a function call in comments.php, and obviously that won’t be possible using wp_list_comments.

    Also, do the new threaded comments come with email notification to the parent-comment author? I suppose this may be answered if/when you reply, of course!

    1. Must be some older plugins then, because they’re doing it wrong.

      get_avatar() is a pluggable function. Meaning that any plugin can override it entirely by simply making a new get_avatar() function in their own code, that takes the same parameters as get_avatar does. If they’d rather not handle all cases, it has a get_avatar filter on the result, so that a plugin can override or modify the output from the normal get_avatar function. Any avatar related plugin should use these instead of requiring the user to modify their theme manually.

      Also, I don’t think notification is built in at this point, but it could probably be easily done in a plugin.

      1. Yes, they were older; I think I’ve figured out how to modify them, though. Thanks!

        One thing I’ve noticed, while going through the new comment structure, though. The lack of a class on the div that encloses each comment (the one that gets id=div-comment-xxx where xxx is the id number of the comment) is going to severely impair some css layout options. If that particular div could be given a class (comment-div or something) that we could use in conjunction with .odd, .even, etc. that would open up the options again. I realize you guys are in bug-swatting mode rather than feature mode, but, as a layout designer, I consider this a fairly significant bug.

        Cheers

        1. What, exactly, does that prevent you from doing? Because that particular DIV is easily referenced directly by simply using “ul.commentlist li div”. There’s no need to add classes on something that is directly referencable without them.

          In fact, classes only are ever necessary when you’re dividing things into more than one of something, not when ALL of that thing are the same.

          You can even reference that div differently for pingbacks, comments, trackbacks, etc, like so: “li.comment div”, “li.pingback div” and so on.

          1. All I can say is that I’ve had problems with similar configurations in the past. If what I want is to, say, give even and odd different background colors, but only around the body of the comment so that the colors don’t nest as the thread goes on, sometimes I’ve run into problems when I reference an unclassed element that’s inside nested classes; the most proximal class is supposed to take precedence, but sometimes the result I get is as though the browser processed it in a different order and decided that all divs inside .even (which means the entire thread) take the even class. This without an inherit order to be seen anywhere. Drove me absolutely nuts. If the element I reference has a class I can use instead of just the element type, that seems to work most reliably.

            Speaking of which, though, I had another thought about the classes while looking at the html here. It seems like ‘byuser’ and ‘bypostauthor’ and ‘comment-author-[name]’ show up in strange positions. Those should come last, yes? Since they are the most likely to need to override other classes? Looking at the source code here, the three in question appear right after ‘comment’, when they appear.

            Cheers

          2. Yeah, I follow you with the class thing now, browsers can be problematic in that way. Still, the spec is pretty clear. And there’s CSS tricks to get around those particular browser issues, if/when they crop up.

            I’m not sure what you mean though with regard to the class ordering. Class order in the element is unimportant, because overriding of attributes happens depending on the order in the CSS file itself. Later elements in the CSS processing cycle override earlier ones. Classes in the HTML are all considered equal, and order doesn’t matter there.

          3. Order does seem to matter. If there are multiple classes listed on one element, and more than one of them is defined via css, then the latest class in the string will be the one that takes precedence, no matter what order the classes are defined in, in the css file. This may vary from browser to browser, but in FF on mac, at least, that’s how it’s working.

            So, for example, I’ve defined even and odd and bypostauthor. No matter what order I put them in on my style.css, bypostauthor does not take effect. (I’m currently playing with a nightly build to test this stuff out.) I’ve been able to get around this by using li.bypostauthor, but wouldn’t it be better to line the classes up in a good order of precedence to start with?

            And, um, if you know a css trick to make that enclosing div take a style without applying it to every other div inside it, could you tell me? I have yet to find a way around that one. If I have to do up a function to add the class just for my own theme, I think I can, but a purely css answer would be better.

            Cheers

          4. Well, if that’s really the case, then your Mac is broken and it is doing it wrong. I cannot duplicate your results in Firefox on Windows/Linux, or IE on Windows. Furthermore, the CSS specification explicitly spells it out the way I’ve said it.

            In actuality, it’s somewhat more complicated than this, but it’s really a matter of specificity. The last rule in the processing chain which is also the most specific rule takes precedence. Equally specific rules (bare classes would be equal) means that the last one counts.

            So, are you sure that you don’t have a more specific rule overriding your other rules here? Even if it’s higher in the file, more specific rules win. The way you describe it, it sounds like you do. Note that li.bypostauthor is more specific than the generic .bypostauthor. And the key to your problem is that a specific rule targeting the comment li’s would likely be in between those two…

            As for your CSS problem, I suspect you’re using the wrong CSS Selectors. Google for “CSS Selectors”. If you don’t want deep children, you don’t have to select them. Like so:
            li.bypostauthor > div { background-color: red; }

            See? The > means to only select the div that has an immediate parent of li.bypostauthor. Simple, eh?

  16. Hi I’ve read that someone has trouble with css classes – css doesn’t support more than 4 classes in a div

    class = 1 2 3 4 and than it is over and out so most of the new classes are not useable for theme authors
    and if you define 1 with color black and 4 with color green -green is the winner πŸ˜‰ so you must be a css guru to style comments individual – I’m sure most of the themes would like very *creative* and our support forum full of *help me!* posts πŸ˜‰ —

    but I have a question to: Password Protection Check

    is this backwards compatible? if not how can I make my themes for free backwards compatible?

    thanks a lot

    Monika

    1. Dunno where you got that idea, but there is no inherent limit to the number of classes that you can add to any element, DIV’s included. The only limitation is browser coding and memory. Modern browsers support well over 2000. I am actually using some of those “past 4” classes for styling on this very site. With all these classes, styling comments individually is actually quite easy, no “guru” status required. πŸ™‚

      The post_password_required() function is new to 2.7, so it is not backwards compatible. If you look at the default theme in 2.6, then you can see the older way to do it. If you want to make this piece backwards compatible, then you can check for function_exists(‘post_password_required’) and use it if that returns true, or use the old way if it returns false. But it is important to use post_password_required() for future forwards compatibility.

  17. I can’t fault the tutorial – but I found it easier installing the beta and modifying the comments.php in the default theme πŸ™‚

    I’ve successfully(!) styled the threaded comments, but where do the numbers come from? You can see the comments on my site at the bottom of this page.

    I also can’t sort out anything to hide the comment form using javascript, and have it appear when a link is clicked.

    1. Scott: As Monika suggests, the OL’s are creating the numbers.

      As for the javascript, I’m not sure what you’re talking about. The form normally shows up at the bottom, and then when you click a reply link, it moves to where that link is. I can’t test it myself, because your site seems to require a login to reply.

      1. Cheers for both your replies – I knew it would be something rather straight forward!

        The form is present at the bottom, and moves to the reply link when clicked, but I misread what was supposed to happen – I thought that the comment box was hidden altogether until “post comment” is clicked, but that isn’t πŸ™‚ So ignore me!

        Thanks again for the replies though.

  18. How is Gravatar support enabled in the new comments loop? I currently have this piece of code:
    echo get_avatar( get_comment_author_email blah blah

    1. You don’t have to do anything. wp_list_comments will make the correct call to add the gravatar as needed. If you have the gravatars disabled in the admin area, then the avatar won’t be added.

      1. Hi Otto,

        Great post – very interesting read. I’m actually wondering what happens if you *do* want to change the default Gravatar size? I’m currently playing with WP2.7b3 and there doesn’t seem to be any options to change the default Gravatar size. I’ve looked under a variety of options (discussion settings, media etc.) and can’t find anything…

        Aside from switching it off and on, do you know if the an option to resize the Gravatar will make it into WP2.7 public release?

        Thanks,

        Zain

        1. Zain, the option name you are looking for is “avatar_size” and it’s mentioned in several other comments on this page. You cannot change the size in the admin, and no, no option will be given to do that. The size of the avatar is properly a theme controlled item, as that affects the style and design of the page itself.

          1. Thanks Otto.

            S’okay, I found it… and a few interesting other features too, like the reverse threading; child reverse threading; separating out comments from trackbacks, controlling the number of comments per page; the text for the reply link as well as the avatar size!

            Will document it when I have a little more time.

            Thanks for the great post. And I get your point about the size of the avatar being theme controlled.

    2. How is Gravatar support enabled in the new comments loop? I currently have this piece of code:
      echo get_avatar( get_comment_author_email blah blah

      1. Avatars are included in the wp_list_comments, you don’t need to call them manually. Just turn them on in the Settings->Discussion screen.

  19. Up till now, I have created my theme to be handling AJAX commenting. But with paging and threading, it is just not going to be that straightforward. It could most probably be done with some extensive checks but it is the paging which is breaking everything apart. Is there a way we could retrieve the number of comments per page via JavaScript?

    Also when will documentation on the wp_list_comments() be released? I want to be able to customize how my comments are listed.

    1. In order for the javascript to have that value, you’ll have to retrieve it and put it in the page somewhere, as a script. In PHP, you can get that value like so: $per_page = (int) get_query_var(‘comments_per_page’);

  20. Thanks for this post, this is the information that I was looking for.
    I am just working on comment enabling for my image gallery.

Comments are closed.

css.php