in WordPress

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>';

} ?>

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email