How To Separate Comments And Trackbacks With Wordpress

By default Wordpress themes will display trackbacks and comments together at the bottom of the post, but you don't really want to display these together it's much better if you can separate these. If you can separate them then visitors can just see all the comments in order and then you can have the trackbacks after these so you are still encouraging people to link to your site. Use the following code and you will be able to use these separately.

Just Display Comments

To just display the comments use the following code.


<h2>Comments</h2>

<?php foreach ($comments as $comment){

     if(get_comment_type() == "comment") {

          echo '<li>'.comment_text().'</li>';

     }
} ?>

Just Display Trackbacks

To just display the trackbacks use the following code.


<h2>Comments</h2>

<?php foreach ($comments as $comment){

     if((get_comment_type() == "pingback") || (get_comment_type() == "trackback")) {

          echo '<li>'.comment_author_link().'</li>';

     }
} ?>

UpChecker

Reliable uptime monitoring and instant alerts for any website downtime.

  • Uptime Monitoring
  • Performance Monitoring
  • SSL Certificate Alerts
  • Domain Monitoring
  • DNS Checker
  • XML Sitemap Monitoring