Customise Comments

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.


<?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.


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

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

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

} ?>
Back to top

Gain access to all tutorials

  • Premium tutorials covering WordPress, Laravel and VueJS
  • Download premium content
  • Download premium WordPress plugins
  • Only $5 a month

Join Paulund