Posts Tagged ‘pingbacks’

How to Separate Comments and Trackbacks

Normally wordpress themes behaviour is to combine both comments and trackbacks / pingbacks together and display under the same list.

To separate editing of comments.php required.

First Step:

Search for:

 <?php foreach ($comments as $comment) : ?>  

Add After this:

<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>

Second Step:

Search for:

<?php endforeach; /* end for each comment */ ?> 

Add After this:

 <?php } else { $trackback = true; } /* End of is_comment statement */ ?>

Third Step:

Search for:

 <?php else : // this is displayed if there are no comments so far ?>

Add After this:

<?php if ($trackback == true) { ?>
<h3>Trackbacks</h3>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type != 'comment') { ?>
<li><?php comment_author_link() ?></li>
<?php } ?>
<?php endforeach; ?>
</ol>
<?php } ?>