Note: For WordPress 2.7 and newer WordPress installations, you’ll instead want to use this tutorial.

With all the WordPress themes available to WordPress users, it always surprises me how these incredible theme authors don’t take a few extra seconds to separate their theme’s trackbacks from the comments. It doesn’t look very professional and it can make it extremely difficult to follow a conversation in the comments.

Separating your trackbacks and comments requires a minimal amount of coding work to set up. First, you’ll want to make a backup of your comments.php file just in case something goes wrong. Next, follow these three steps:

1 ) Access your comments.php file and locate the following code:

<?php foreach ($comments as $comment) : ?>

Immediately after the above code, you’ll want to place this code:

<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>

2 ) Next, you’ll want to scroll down a little bit and locate the following code:

<?php endforeach; /* end for each comment */ ?>

Immediately before the above code, you’ll want to place this code:

<?php } /* End of is_comment statement */ ?>

This will filter out all of the trackbacks and pingbacks from your main comments loop. Now we need to create a second comments loop to display the trackbacks and pingbacks.

3 ) Almost immediately below the code from step 2 you should find this code:

<?php else : // this is displayed if there are no comments so far ?>

Immediately before the above code, you’ll want to place this code:

<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>

You can adjust this code to display how you want to, including using a different header if you have a specific look for your header 3.

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

  • Pingback: WordPress Theme Tip: Separate Your Trackbacks From Your Comments

  • http://www.garryconn.com/ Garry Conn

    Great article man. I found it after my friend Kyle from Kyle’s Cove included a reference to it in his article. Nice work man!

  • Pingback: Geri izlemeleri yorumlardan ay?r?n, email abonelerinize toplu mesaj gönderin

  • http://pomomusings.com Adam

    i like the article, but do you know how i can list the number of trackbacks….

    Yours above says 3 Responses…

    Could it say 3 Trackbacks too?

  • Hack WordPress

    Adam – Glad you found the post useful!

    With my current setup, the comments loop starts after it grabs the number of comments from the database, causing it to group the comments and trackbacks into a single total.

    Unfortunately, WordPress handles trackbacks/pingbacks and comments in the same way (which is why you have to approve trackbacks like you would a comment). Therefore, it would be extremely difficult to code your comments.php file to pull them separately.

  • Jenny

    Oh good I’ve been trying to figure out how to do this. Thanks!

  • Hack WordPress

    Jenny – Glad you found it useful!

  • Pingback: How To Separate Comments and Trackbacks On A WordPress Blog

  • Pingback: Oddzielamy TrackBacki od komentarzy - Polski Blogger

  • http://bloggerpl.com/ blogger pl . com

    Adam,
    to count comments and trackbacks separately you should try as follow: immediately after line

    put that code:

    and then simply show right number as number of comments or trackbacks.

  • http://bloggerpl.com/ blogger pl dot com

    ups, it seems that code I wrote isn’t displayed, than again:

    <?php
    $numTrackBacks = 0;
    $numComments = 0;

    foreach ($comments as $comment) {
    if (get_comment_type() != “comment”) { $numTrackBacks++; }
    else { $numComments++; }
    }
    ?>

  • Pingback: Reader Tips: 21 October 2007

  • http://InternetDuctTape.com engtech

    Not quite the same thing, but I have two RSS filters for separating my comments and trackbacks in my RSS feeds in NetVibes — so I can always see the last 5 commenters.

    http://internetducttape.com/2007/09/25/blog-maintenance-tip-netvibes-start-page/

  • http://www.problogdesign.com/ Michael from Pro Blog Design

    Heck of a post. ;)

  • Pingback: Reader Tips: 21 October 2007 | MegaBlogg Free Blog Host

  • Pingback: Randy Roedl On Wordpress Blogs

  • Pingback: GroundFloorSEO.com Syndicated SEO News » Reader Tips: 21 October 2007

  • Pingback: How To Separate Comments and Trackbacks On A WordPress Blog | FUN???up UP

  • http://www.bicyclefrenzy.com Bradly Fletchall

    This is great stuff. This is by far the esiest to understand WordPress Theme adjusting I have done since I switched to WordPress a few months ago. I’m going through the other articles looking for other golden nuggets of knowledge I can use on my site.

  • Pingback: Cool Links - 10-25-07

  • Hack WordPress

    Blogger PL – Thanks for contributing the extra code!

    Engtech – That is definitely useful. Thanks for providing the link.

    Michael – Thanks! Hope you check back for future updates.

    Bradly – Glad you found it useful! I try to discuss various news, tips, tricks, hacks, and WordPress plugins/theme reviews, so if you find that stuff useful feel free to subscribe to my feed!

  • http://www.twentysteps.com Mike – Twenty Steps

    That’s a great workaround and something I’ve just implemented on my site. Thanks for putting it out there.

  • http://digital-musings.com Vikram

    Hey! It works! This mix up of trackbacks and comments was really pissing me off, but this is a great Tutorial, they each have their own territory now!

    Cheers! Great job!

  • http://blog.krefftwerk.net mk

    Duh! First of all, thanks for pointing out that this is a themes issue. :-)

  • Pingback: pBlog, Personalize seu blog Wordpress » Blog Archive » Como separar os comentários dos trackbacks/pingbacks

  • http://secondavenuesagas.com Ben K.

    Thanks for this one. The Comments/Trackback issue was really bugging me.

  • Pingback: Gabfire » Tracbacks and Email subscriptions

  • Pingback: Tracbacks and Email subscriptions

  • Pingback: Feedweiser Theme Version 1.0 | Feedweiser

  • Pingback: 50 tips y trucos para optimizar Blogger y WP | Blog en Serio

  • Pingback: 25 hacks para dinamizar seu Wordpress! — Bytes a Go-go!

  • Pingback: Separate WordPress Comments and Trackbacks « weblife

  • Pingback: Separate WordPress Comments and Trackbacks « ForNext » Learning to be ignorant

  • Marc

    I wanted to separate them but thought it might be too complicated. Thanks for the tip.

  • jrgd

    Thanks for all those explanations: I just did it and it’s quite nice to have trackbacks and comments separated now, I really like it! Thanks!

  • Pingback: assembling » Blog Archive » links for 2008-02-04

  • http://www.valmg.com valmg

    Awesome post! Very helpful and looks terrific when implemented. It was easy to put on this blog, I’ll be putting it in place on my others as well. Thanks! Great work!

  • Pingback: Wordpress comments, trackbacks and pingbacks | Computer Chit Chat

  • Pingback: WordPress Trackbacks And Comments | LimeTouch

  • Pingback: How To Separate Comments and Trackbacks On WordPress : Yeepage

  • Pingback: 63 Essential Wordpress Hacks, Tutorials, Help Files and Cheats | Speckyboy - Wordpress and Design

  • Adam Kayce

    Beautiful! This worked exactly as I wanted it to, even taking out the trackback text, and it did it in about five minutes.

    Thanks so much (you saved my hide).

  • Pingback: 63 essenziali Wordpress Hacks, Tutorials, Help Files e Cheats : technorati.it

  • Pingback: Wordpress Tutorials/Hacks « The house of software freeware

  • http://www.nela.in/ moserw

    Thanks for sharing this. Will check it out.

    http://www.nela.in/

  • Pingback: Blog Wordpress, come separare i commenti dai trackback - Geekissimo

  • Pingback: 20 Places For Wordpress Hacks | Index Blog

  • Pingback: 20 Ways To Get More Blog Comments

  • http://www.mactricksandtips.com Mac Tips

    Is there a way to set it up so it says a line of text if there isn’t any trackbacks. In a similar way to comments. Otherwise a very good tip. Thanks

  • Pingback: How to Attract More (Productive) Comments to your Blog Posts | PandemicBlog

  • http://www.valdau.lt Monika

    is it correct?
    foreach ($comments as $comment) {
    if (get_comment_type() != “comment”) { $numTrackBacks++; }
    else { $numComments++; }
    }

  • Kevin

    Definitely a great help! Simple and clean, thanks.

  • christine

    This is a really great post. Thank you.

    How do you separate Recent Comments from Recent Trackbacks in your sidebar?

    My Recent Comments is now a widget that came with the (Revolution) theme, but it shows the comments and trackbacks all mixed together.

    And even more annoying, it shows trackbacks from internal links between my own articles. Does the code above prevent that? or do you have to somehow exclude it from showing trackbacks where you yourself are the author, or from your own URL, or something like that?

    I’m going to look through your other posts for other good things.
    Thanks again.

  • http://kyleeslick.com Kyle Eslick

    @ Christine – If you are already using the Revolution theme, it should be really easy! You use the Recent Comments plugin provided.

    With that plugin you can sensor out internal pings and set up trackbacks to be separate. You should see a trackback tab.

    I’ll put this on my list of posts to tackle in the near future, so subscribe or check back regularly!

  • christine

    Thanks, Kyle.
    I have a Recent Comments widget, but I can’t get in to change anything about it.
    There is no Recent Comments plugin. That one you mentioned sounds excellent. I’ll go look for it, instead of the widget.
    If you know of a good one, could you post a link?
    Thanks again.

  • christine

    I think I found it. It’s called Get Recent Comments, right?
    I wonder if it was there at the start and I somehow lost in during the 2.5 upgrade.
    On the plugin in page, here

    http://blog.jodies.de/archiv/2004/11/13/recent-comments/

    it says “Widget support (but not required)”. What does that mean?

  • http://kyleeslick.com Kyle Eslick

    @ Christine – Yes, that is the correct plugin.

    I don’t use widgets, so I think they are just saying widget use isn’t required.

    I will try to get up a plugin review within the next week for this plugin. Hopefully that will give you the information you need. :D

  • Pingback: 155 Wordpress Resources, Tutorials, Plugins, Themes, AJAX, Podcasting…WP Monster List | Speckyboy - Wordpress and Design

  • Slave to the Internet

    Hey, thanks for this little hack! Works a treat and has really cleaned up my comments!!

  • http://pacura.ru ovidiu

    hello there.
    I have done things like this mods, but I would want my trackbacks/pingbacks to look more like they look in my comment section of the admin panel, with all that text around the link to my site, not just the link from where they resulted… but when I tried to use $comment->comment_text it gave me noting back :-(

  • http://pacura.ru ovidiu

    oh and by the way there is a plugin to do this separation: http://www.binarymoon.co.uk/projects/bm-track-ping/

  • http://www.eventurebiz.com John Hoff – eVentureBiz

    Thanks for the info. I just put it on my blog and love it. I stumbled it and you can count on a trackback!

    What do you think about creating the list, however, below the Submit comment box though?

  • http://kyleeslick.com Kyle Eslick

    @ John – That is up to you. I display them just below the comments because it serves as a reminder to readers that they can write about the post on their site and get a link displayed there. I also know they can sometimes generate traffic for people, so I like having them in blue.

  • http://www.bojhan.nl Bojhan

    How do I remove the Trackback when there are no trackbacks? And dispaly when there are.

  • Pingback: 155? WordPress ????????????AJAX???…… —— WP ???? | Awesomer

  • Pingback: Hack WordPress | eVentureBiz Blog - Entrepreneurship and Succeeding Online

  • Divvy

    Great hack, congratulations!!!

    Btw, is there any code that makes possible to not count the trackbacks/pingbacks in the number of comments?

    For example, in a post I have 5 comments.
    1 for a user and 4 trackbacks.
    I only want to show 1 instead of 5.

    Is possible? how? :)

    P.S. I dont know if the “blogger pl dot com” code is correct for me, but I dont know where to put him…

  • Divvy

    blogger pl dot com, where is to put that code?

  • Pingback: Wordpress’in Kompetan? Olun! 2 | Bili?im Sözlük

  • Pingback: Guesworld.Com | Graphic is Life

  • Pingback: To Ping or Not to Ping Your Posts | I'm Blogging That!

  • Pingback: IndoProTech.com

  • Pingback: elbandito.us » Blog Archive » Tutoriale si hack-uri pentru wordpress ( lista mare )

  • Pingback: 63 correções, tutoriais, arquivos de ajuda e dicas essenciais para Wordpress | Rafael Bernard Araújo

  • Pingback: Compilation of WordPress Hacks

  • http://www.direitodigital.blog.br José Vitor Lopes e Silva

    I can’t do this. Always fail :(

    My comments.php http://josevitor.pastebin.org/51897

    I’m using WordPress Thread Comment plugin.

  • Pingback: Webmaster’s Blog » Blog Archive » How To Separate Comments and Trackbacks On A WordPress Blog

  • Pingback: Wordpress Hacks, Guides and Tricks | TechnoBuzz.net

  • Pingback: WordPress ?? ??? ??? snippet

  • http://takriv.com Lior Iluz

    Amazing! greatly appreciated!

  • Pingback: Top 30 Most Wanted Wordpress Tricks and Hacks | Make Money Blogging Experiment

  • avtorentacar

    Thank you.

  • http://forthardknox.com Ron

    Can I move the code to display trackbacks before the comments? If so, where would I put it?

  • Pingback: WordPress Developer’s Toolbox | Developer's Toolbox | Smashing Magazine

  • Pingback: WP?????-2.5: WordPress????????? | ????

  • Pingback: Wordpress ile ilgili 155 kaynak « YEAH28 - Her ?ey Sizin ?çin

  • Pingback: WordPress Developer’s Toolbox | rafdesign

  • Pingback: Lo mejor de la semana XLXIV

  • Pingback: Best of WordPress Tutorials – More than 100 recourses | Tutorials | .:Lirent.net Hacks:. | All about Web 2.0, SEO, PHP5, Ajax, Adsense, Unix/Linux, Free Stuff, OpenSource, Designs, Wordpress, Hi-Tech etc

  • Pingback: How To: Separate WordPress Comments and Trackbacks | ear-fung.us

  • http://www.avani-mehta.com Avani-Mehta

    Thank you. I could figure out how to not show trackbacks along with comments. Was stuck over how to show them in the end. This makes things quite speedy.

  • Pingback: How To: Separate WordPress Comments and Trackbacks - 2DP Marketing System Blog

  • http://www.seomkt.com bbrian017

    I did this modification and now comments or my sidebar won’t display using internet explorer can you possibly help me?

    I’m off back to work for the afternoon but if you add me (msn) to the e-mail I’m replying with maybe around 5 this evening you can help me get it right?

    open my url here and use Internet explorer and you will see

    works fine when using firefox!

    p.s. I have subscribed!

  • Pingback: Vote for this article at blogengage.com

  • http://www.seomkt.com bbrian017

    Sorry this works perfect!

    Thanks it was a bad post that messed up the page!

  • Edward de Leau

    Just a note that under 2.7 all of this has changed with the new wp_list_comments

  • http://www.thechetan.com/ Chetan

    Working excellent.
    Thanks a lot.

  • Pingback: Tired of those ugly trackbacks? - Blog Forum - Bloggeries

  • Pingback: Links of the Week: December 19th | Bainbridge Studios

  • Pingback: Resources Every WordPress Theme Developer Should Know About! | Arbenting

  • Pingback: Introducing Tweetbacks Plugin for Wordpress | Developer's Toolbox | Smashing Magazine

  • Pingback: Introducing Tweetbacks Plugin for Wordpress | Developer's Toolbox | Smashing Magazine

  • Pingback: Introducing Tweetbacks Plugin for Wordpress | Developer's Toolbox | Smashing Magazine

  • http://www.shoutmeloud.com p@r@noid

    Cool Thanks for the tips..Worked for me :)

  • Pingback: Introducing Tweetbacks Plugin for Wordpress « ArticleSave

  • Pingback: Introducing Tweetbacks Plugin for Wordpress | Web Hosting and Domains

  • Pingback: Introducing Tweetbacks Plugin for Wordpress | The Blog Specialist

  • Pingback: WordPress Theme Wrap Up (part 2) « Web and New Media

  • Pingback: Introducing Tweetbacks Plugin for Wordpress | SuperBlog

  • Pingback: Wordpress Tema Tasar?mc?lar? ?çin Kaynaklar | Sinerjik Günlük

  • David Gonzales

    Thanks!

  • http://saarlodri.com Andreas

    Thank you for this article. It’s exactly what I’ve searched for!

    Greets

    Andreas

  • Pingback: ~ iLGinciX ~ iLGinciX ~ iLGinciX ~ iLGinciX ~

  • Pingback: Tema Tasar?mc?lar? ?çin Kaynaklar | iLGinciX TEAM

  • Pingback: Top 50 Wordpress Tutorials - NETTUTS

  • Pingback: 50???WordPress?? at ??????

  • Pingback: Top 50 Wordpress Tutorials

  • http://www.freegameshero.com/ fun free games

    This is working excellent.
    Thanks a lot.

  • Pingback: 50???WordPress?? | ???

  • Pingback: Top 50 Wordpress Tutorials | Web Design,Photoshop Tutorial,Design News

  • Care Egypt

    it’s adorable …
    really thank you so much
    Greeting from Egypt

  • Pingback: Threaded Wordpress Comments: The Right Way « Jeremy Poradek

  • Pingback: 135+ Ultimate Round-Up of Wordpress Tutorials | About Us | instantShift

  • Pingback: Hityun????? » 50???WordPress??

  • http://www.flapane.com/ flapane

    Works great, thanks.
    IMHO a nice thing could be deleting the pingbacks from comments count.
    So if there are 4 comments and 3 pings, the post shows: 4 comments, and not 7 comments.

  • Pingback: 135+ Ultimate Wordpress Tutorials

  • Pingback: Bili?im Mahallesi! » Blog Archive » Wordpress Tema Tasar?mc?lar? ?çin Kaynaklar

  • Pingback: ?ª]V[ªX » Wordpress Hacks und Plugins

  • http://www.thebadblogger.com The Bad Blogger

    Thanks for the information, now my blog looks better…

  • Pingback: 70 Very Useful Wordpress Hacks & Tricks » De Web Times - Sharing Useful Resources.

  • http://www.seomkt.com bbrian017

    I tried using this with my new theme from elegant theme but no luck yet with the suggested “finds”

    I’ve been waiting weeks for a reply in and attempt inside their forums for the cherrytruffle theme.

    I simply loved this hack it’s by far something that should be added in all wp themes!

  • http://www.joyoge.com/ joyoge designers’ bookmark

    nice tip thanks for the tut..

  • Pingback: 10 Extremely Useful WordPress Hacks And Tips | Tweeaks Design

  • Pingback: 20+ Tutorials For WordPress Theme Developers | oOrch Blog

  • Pingback: Top 50 Wordpress Tutorials « The Interweb of TJ

  • Pingback: How to not count number of trackbacks with comments number | reADactor

  • Pingback: Tutorial: Kommentare und Trackbacks tren… | Wordpress Lesezeichen

  • Pingback: 50 Wordpress Tutorials « Uttammitra’s Blog

  • Pingback: bulldoggie studio » Top 50 Wordpress Tutorials

  • aks

    nice tutorial thanks for sharing.

  • Pingback: Top 50 Wordpress Tutorials from TutPlus | WordPress News Magazine

  • http://www.uzmanparke.com/ ankara parke

    This is great stuff. This is by far the esiest to understand WordPress Theme adjusting I have done since I switched to WordPress a few months ago. I’m going through the other articles looking for other golden nuggets of knowledge I can use on my site.

  • http://www.kapadokya.net kapadokya

    Beautiful! This worked exactly as I wanted it to, even taking out the trackback text, and it did it in about five minutes.

    Thanks so much (you saved my hide).

  • Pingback: top 50 tutorials of wordpress(must use) | Umraz Ahmed | the official site

  • Google Experience

    This does not work for me. With a pingback all the comments are gone and no way to fill it in. I don’t have any knowledge and I can’t solve this problem… Have to look further for another solution.

  • http://www.mxky.com Infographiste

    Oh good I’ve been trying to figure out how to do this for a customer and it helped me, so thanks for sharing the “tip” :)

  • Pingback: Top 50 Wordpress Tutorials | NetExUrl | Web Development Tutorials & Design Resources

  • Pingback: 65 Of The Best WordPress Tutorials « Junkiee.Net

  • Pingback: 70 Very Useful Wordpress Hacks & Tricks | biroattila.com | Innovation and web

  • http://www.cssrex.com/ CSSReX

    Thanks for this wonderful code! My theme was showing track backs in between comments which does not look good. Now its wonderful!
    Thanks once again!

  • Pingback: Wordpress Hacks « reeboot strategy

  • Pingback: Wordpress Hacks And Customizations « MoeMir

  • Pingback: Wordpress Hacks e Customizations! | sinergie.::.websolution | il blog

  • Pingback: Geek is a Lift-Style. » Blog Archive » Introducing Tweetbacks Plugin for Wordpress

  • Pingback: Geek is a Lift-Style. »Archive » Introducing Tweetbacks Plugin for Wordpress

  • Pingback: 60+ Awesome WordPress Tutorials | The Best WP Themes Online

  • Pingback: 50 Ultimate Tutorials To Make You A Power Wordpress User | stylishwebdesigner

  • http://www.vabytech.com vivek

    Works a treat and has really cleaned up my comments!!

  • Pingback: 136 Massive Wordpress Tutorial Collection | WebCoreStudio

  • Pingback: » 50???WordPress?? @ Cloud 1989

  • Pingback: HOWTO : separare commenti e trackbacks in Wordpress | Flavio's blog

  • http://robcubbon.com/blog Rob Cubbon

    I found this really useful as well. Thanks.

  • Oris WilliamsF1

    I’m going through the other articles looking for other golden nuggets of knowledge I can use on my site.

  • http://words-do-matter.blogspot.com/ deepika

    can’t this be installed on blogger? :(

  • http://www.rehaupvc.com rehau

    I am using a theme that runs on Thematic so I can find the “foreach” you mentioned but not