I spent pretty much every waking moment I had at home this weekend trying to wrap my head around the new comment loop in WordPress 2.7. Otto’s detailed explanation was helpful, but did not give me a way to “break down” the new
Finally frustrated, I hit the WordPress forums and mailing lists. Several posts in the forums pointed to Justin Tadlock’s recent post about making themes backwards compatible. Basically, you save a copy of your current (2.6) comments.php file and name it legacy.comments.php. Then add a small bit of code to your theme’s functions.php file:
This IS very useful and I’ll be needing it to update my released themes, but not quite what I was looking for for updating this site. Checking WP-Hackers, I hit gold — a post by Ryan Boren a couple months back detailing how to separate pings from comments gave me the nudge in the right direction that I had been looking for.
I don’t know why it never occurred to me before now, but using a callback allows you to breakdown a function (similar to the
foreach loop used for comments in previous versions of WordPress). Hitting the forums again, I found a reference to Jeremy Clark’s post on using the comment callback function. This gave me exactly what I needed.
I used Jeremy’s comment threading post as a starting point for my comments.php file (view code). I fixed the alignment of most of the coding to make it a little easier to follow (and muck about, LOL).
Here’s a close-up of my modified the wp_list_comments reference:
Here I am changing the avatar size to 70 and will be using a callback function called “custom_comment” to format the results of the loop. Also, notice that the type is set to ‘comment’. For the time being, I am showing only comments (no trackbacks/pingbacks) until I figure out how I want them styled.
Now on to the functions.php file to show you how I formatted and corralled everything (view code).
Taking this route seems a bit overwhelming at first but IMO is the best way to go if you want your comments to look and/or behave a certain way.
Last but not least
If you haven’t already, don’t forget to add this snippet to your theme’s header.php file:
As shown in my example, make sure you add it before the
I hope this all makes some kind of sense. Please feel free to ask me to elaborate on anything I’ve posted here and I’ll try my best to explain!