Posted By

selfmadepsyche on 02/17/09


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Bluewall


Separate WordPress Comments and Trackbacks


 / Published in: PHP
 

URL: http://wphacks.com/how-to-separate-wordpress-comments-and-trackbacks/

  1. 1 ) Access your comments.php file and locate the following code:
  2.  
  3. <?php foreach ($comments as $comment) : ?>
  4.  
  5. Immediately after the above code, you'll want to place this code:
  6.  
  7. <?php $comment_type = get_comment_type(); ?>
  8. <?php if($comment_type == 'comment') { ?>
  9.  
  10. 2 ) Next, you'll want to scroll down a little bit and locate the following code:
  11.  
  12. <?php endforeach; /* end for each comment */ ?>
  13.  
  14. Immediately before the above code, you'll want to place this code:
  15.  
  16. <?php } /* End of is_comment statement */ ?>
  17.  
  18. 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.
  19.  
  20. 3 ) Almost immediately below the code from step 2 you should find this code:
  21.  
  22. <?php else : // this is displayed if there are no comments so far ?>
  23.  
  24. Immediately before the above code, you'll want to place this code:
  25.  
  26. <h3>Trackbacks</h3>
  27. <ol>
  28. <?php foreach ($comments as $comment) : ?>
  29. <?php $comment_type = get_comment_type(); ?>
  30. <?php if($comment_type != 'comment') { ?>
  31. <li><?php comment_author_link() ?></li>
  32. <?php } ?>
  33. <?php endforeach; ?>
  34. </ol>

Report this snippet  

You need to login to post a comment.