The most time consuming aspect of my new design (code-wise) was the comments.php template. I already had a few features, such as author highlighting (via a plugin), gravatars, live previews, etc. enabled from my previous design, but this time I decided to bring it full circle and add very important features like alternating styling and separation of comments from pingbacks. I looked up some code from around the web to get the job done and I noticed there aren't too many resources offering a standalone comments template that's easy to build on (and doesn't require a platform theme like K2). So I decided to share my comments.php file (with some modifications to make it even more flexible).
Here is the php source file: comments.phps. You can download this file, rename it to comments.php, and drop it into your theme directory to use it.
It's a rather large file, but I added comments where appropriate so you can figure out what's going on. As I mentioned, you can drop it in as-is and it should work fine (with WordPress 2.0+ at least and probably even 1.5+). It has some code taken from the Author Highlight plugin which I modified heavily to contain the functionality in this comments template.
Here's a quick rundown of what this file offers:
- Trackback link
- Ordered list of trackbacks/pingbacks with total number displayed and without messy pingback text
- Ordered list of comments with total number displayed and author/date separated from content
- Striping of all comments (
class="odd/even") as well as highlighting of author comments (
- Standard comment form that is only slightly different from the one in the default WordPress template
- Code-comments to call out where you can add Gravatar and Live Preview plugin calls
- Option to change author name, author e-mail, and class name for author comment highlighting
Hopefully the comments in the code are enough to make everything clear. I provided a lot of classes and ids to make the file CSS-ready and the file should validate as XHTML 1.0 Strict/Transitional. If anyone needs more information, I might be able to provide it in a week or so when I have the time. I might also be able to post some example CSS for making the comments look clean and easy to read. Until then, enjoy the template file and let me know what you think.
P.S. If you are wondering what this template file can produce, it's pretty close to the comments section of this site, without all the fancy CSS styling.