• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Tips and Tricks HQ

  • Home
  • Projects
    • All Projects
    • Simple WP Shopping Cart
    • WP Express Checkout Plugin
    • Accept Stripe Payments
    • WP Download Monitor
    • Easy HTTPS Redirection
    • WP Security and Firewall Plugin
    • WP eStore Plugin
    • WP Affiliate Platform
    • WP eMember
  • Products
    • All Products
    • Checkout
  • Support
    • Support Portal
    • Customer Only Forum
    • WP eStore Documentation
    • WP Affiliate Software Documentation
    • WP eMember Documentation
  • Contact

How to Separate Pingbacks and Trackbacks from Comments

Home » Blog » How to Separate Pingbacks and Trackbacks from Comments

Last updated: May 22, 2010





According to Wikipedia “A trackback is one of three types of linkbacks, methods for Web authors to request notification when somebody links to one of their documents. This enables authors to keep track of who is linking, and so referring, to their articles”.

separate_coment_trackback2_128

Most bloggers don’t show pingbacks and tracbacks on their blog but if you want to show them then I recommend separating pingbacks and trackbacks from the comments. The main reason I like to separate them is because comments are sometimes an ongoing conversation and trackbacks in the middle kinda breaks the flow of the conversation.

Here is how you can separate the pingbacks and trackbacks from the comments.



search for the following line in your comments.php template file

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

Put the following two lines just after the above line.

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

Now look for the end of the ‘for’ loop so you can close the if statement that you just introduced. To do that search for the following line

endforeach;

Just above that line insert the following code to end the if statement


<?php } ?>

This will filter out the trackbacks and only show comments in this section. If you don’t want to show the pingbacks and trackbacks then you are done. If you do want to show the trackbacks just after the comments section then insert the following piece of code just after the end of for loop section (search for endforeach;)


<?php
/* Loop through comments to count the total pingbacks */
$numPingBacks = 0;
foreach ($comments as $comment) {
if (get_comment_type() != "comment") {
$numPingBacks++;
}
}
?>
<?php if ($numPingBacks != 0) { ?>
<h4>Backlinks/Trackbacks</h4>
<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>
<?php } ?>

To see a demo of how this will look like (comments and trackbacks separated) see my WordPress PayPal Shopping Cart plugin post that has quite a large number of trackbacks and comments. I hope this helps.

Related Posts

  • Protect your WordPress site/blog from comment spam trick
  • How to import WordPress SQL database backup file without having ‘create new database’ privileges in phpMyAdmin
  • How to Install WordPress on Your Domain
  • Top 15 Search Engine Optimization (SEO) Techniques I Forget to Do

Wordpress Web Development,  web masters,  Wordpress

Reader Interactions

Comments (5 responses)

  1. admin says:
    March 17, 2009 at 2:54 am

    Sorry, can’t help you with the default wordpress theme as it uses the ‘wp_list_comments’ method to list the comments. You will have to change a fair bit of code in the comments.php to be able to seperate the trackbacks from comments.

  2. psd graphics says:
    March 15, 2009 at 9:06 pm

    There is no this line

    in default theme, in comments.php

    There is a similar line in comments-popup.php

    Also, there is no “endforeach;” in any of php files in default theme.

    Any help?

Leave a Reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Featured & Popular Articles

Video Answers to Top WordPress QuestionsWordPress Optimization Tips and Tricks for Better Performance and SpeedEssential WordPress Security Tips - Is Your Blog Protected?WordPress Simple PayPal Shopping Cart PluginTop 15 Search Engine Optimization (SEO) Techniques I Forget to DoList of the Best and Must Use WordPress PluginsHow do I Start a Blog and Make Money Online?Good Domain Name Picking Tips for Your Blog SetupFind Out Which WordPress Web Hosting Company Offers the Cheapest and Reliable Web Hosting Solution

Featured WordPress Plugins

WP Express Checkout Plugin
wordpress estore plugin
wordpress membership plugin
wordpress affiliate plugin

Recent Posts

  • How to Use Browser Developer Tools to Inspect Elements and [...]
  • Accept Donations via PayPal from Your WordPress Site Easil [...]
  • Buy Now Button Graphics for eCommerce Websites [...]
  • Subscription Button Graphics for eCommerce Websites [...]
  • Adding PayPal Payment Buttons to Your WordPress Sidebar Ea [...]

Comment & Socialize

  • @Rob, We have just released ...
    - admin
  • I installed the plugin a co ...
    - Rob
  • @Sebastian, We've released ...
    - admin
  • I've used this plugin on a ...
    - Sebastian Djupsjöbacka
  • @John, this plugin doesn't ...
    - admin

Check out our solutions

View our WordPress plugin collection and start using them on your site.

Our WordPress Solutions

Footer

Company

  • About
  • Privacy Policy
  • Terms and Conditions
  • Affiliate Login

Top WordPress Plugins

  • Simple Shopping Cart
  • PayPal Donations
  • WP Express Checkout
  • WP eStore
  • WP eMember

Blogging Tips

  • How to Start a Blog
  • Selecting a Good Domain
  • Cheap WP Hosting
  • WP Video Tutorials
  • Simple SEO Tips

Search


Keep In Touch

Copyright © 2025 | Tips and Tricks HQ