WordPress 2.7 introduced new way comments displayed on your blog and also a new function to display it wp_list_comments. But what do you do if you need more control of How comments displayed and What is included into each comment?

I had to solve this problem in order to get WP Twitip ID plugin working on my blog again! Here are detailed steps on how you too can take control over comments.php loop in WordPress 2.7

I was forced to learn and implement everything due to a SezWho plugin, which was previously used on my blog been sold to another company and I didn’t like what they had to offer. As a side benefit from this conversion – my blog became faster!

But there were some challenges, specifically integration of one plugin I love and recommend using WP Twitip ID, which allows commenter to also provide their Twitter ID and build followers by commenting on my blog.


I’m not going to go into too many details on Why I did things the way I did but simply specify how You Too can control comment loop on your blog and I will also show you how to separate pings and trackbacks from regular comments!

Comments.php File Editing

I took the basic comments.php file from WordPress 2.7 Kubrick theme and modified for my blog, while by default it will work – here is what I have done.

Replace this code:

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

With this code, it will call for our custom function to be created in next step and also separate Comments from Trackbacks and Pings:

<ol class="commentlist">
<?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
<?php endif; ?>
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<h3 id="pings">Trackbacks/Pingbacks</h3>

<ol class="commentlist">
<?php wp_list_comments('type=pings'); ?>

Great job!

You have just managed to get your comments to be compatible with WordPress 2.7 and also split them based on conversation type! Now we will move to step 2…

Add Custom Function to Functions.php file

In previous step we used this call to a custom function: callback=mytheme_comment and now we have to actually create it in your theme functions.php file in order for the process to work.

So navigate to Appearance -> Editor and open functions.php file for editing (you might have to use cPanel file manager if unable to edit directly from blog). Place this code somewhere in your file but be sure you do it before the file is closed, each theme can be different – in my theme I placed it right before the ?> closing tag:

Unfortunately I can’t show the entire code for you properly on my blog page, so I provide you with text file you can download, that includes the function. Click to Download

Within that function you will also find code for integration of the WP Twitip ID plugin, if you don’t plan to use it simply delete the line:

<?php if(function_exists(wp_twitip_id_show)) { wp_twitip_id_show("auto"); }?>

Integrating that function virtually gives you full control over the appearance of your comments and style it as you want it, just like in legacy comments.php file.

Step 3 – Edit single.php file

This one is needed to properly display all our new functions on your Single Post page.

Edit single.php file and replace this:

<?php comments_template(); ?>

With this:

<?php comments_template('', true); ?>

So there you have it! Simple way to take control of the comment loop in WordPress 2.7+ using custom function!

Let me know what you think?!