wordpress snippets last updated   : October 6, 2014
we now have 641 snippets

Separate trackbacks from comments

wordpress snippet

Adding this code to your comments.php replacing the default comments loop will allow you to separate trackbacks from comments.

snippet :  PHPcopy
<ul class="commentlist">
    <?php //Displays comments only
	foreach ($comments as $comment) : ?>
       	<?php $comment_type = get_comment_type(); ?>
       	<?php if($comment_type == 'comment') { ?>
	    <li>//Comment code goes here</li>
	<?php }
    endforeach;
</ul>

<ul>
    <?php //Displays trackbacks only
	foreach ($comments as $comment) : ?>
       	<?php $comment_type = get_comment_type(); ?>
       	<?php if($comment_type != 'comment') { ?>
	    <li><?php comment_author_link() ?></li>
	<?php }
    endforeach;

</ul>
source →

Did you like this post? If so please share it with your friends. Thanks!