How To Control Comments.php In WordPress 2.7
- WordPress Guide – Dissection Of File Structure
- WordPress Guide – Dissection Of WordPress Theme
- WordPress Guide – Customizing WordPress Theme Part 1
- WordPress Guide – Customizing WordPress Theme Part 2
- WordPress Guide – Customizing WordPress Theme Part 3
- WordPress Guide – Enhancing Image System
- WordPress Guide: Howto Force Your Blog Load Fast
- WordPress Guide – Installing Plugins And Themes
- How To Control Comments.php In WordPress 2.7
- 5 Steps To Practical WordPress Security
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(); ?> </ol>
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'); ?>
</ol>
<?php endif; ?>
<?php if ( ! empty($comments_by_type['pings']) ) : ?>
<h3 id="pings">Trackbacks/Pingbacks</h3>
<ol class="commentlist">
<?php wp_list_comments('type=pings'); ?>
</ol>
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?!
Tags: guide, howto, howto-guides, WordPress, wordpress guideTechnorati: guide, howto, howto-guides, wordpress, wordpress guide,













Although I don’t use this particular twitter plugin, I do like to experiment.
Thanks for your tips on enhancing and reducing issues with this one.
I’m definitely not one to get as technical with WP as you do, so everything you offer is a big help to me!
George Packards last blog post..DALE CHAVEZ STERLING SILVER FERRULED SHOW HALTER
Wow, thanks for the heads up… That seems fair to control comments and make sure that they are legit comments and not spam…
Terrance Charles
http://www.twitter.com/terrancecharles
Thanks for the tips and step-by-step way of presenting this.
I am due to launch a new blog as the front end of my now centralized product delivery system and wouldnt mind appying this to that blog.
But being the cautious kind, I’ll test it all out on a test blog before implementing it on my live site in case I break something.
If you have no test blog backup the files you intend to edit to avoid frustrating surprises. Its happened to me before so now I prefer the slow steady progress approach :p
I like the twitter touch
Williams last blog post..Google & Your Competitors Will Need Tissues!
Great points William – testing backup is a MUST.
I generally verify by looking at the *.sql file, which is essentially same thing
I haven’t upgraded yet, but I appreciate the heads up.
Dennis Edells last blog post..UPDATED! Opening INTERNAL Links- New Window or Same Window?
That theme is useful for me and hope for others also. Nice Work…
Thanks for the tips.
Sajids last blog post..Wordpress Featured Content Slideshow Gallery Plugin
Being new to the marketing “world” I cannot believe the information I have gained from this site. Thank you I will be back!!Our site please check us out