This tutorial will explain how to change or hide the display of Trackbacks/Pingbacks in WordPress. You can see an example of this.

This post follows on from my nicer trackbacks plugin and post on improving comment section readability.

  1. Open your Comments Template and look for the sort of code below (yours may look different, depending on your theme). I’ll refer to this code as the display code.

    <li class="<?php echo $oddcomment; ?>" id="comment- <?php comment_ID() ?>">
    <cite><?php comment_author_link() ?> Says:
    <?php if ($comment->comment_approved == '0') : ?>
    <em>Your comment is awaiting moderation.</em>
    <?php endif; ?>
    <br />
    <small class="commentmetadata"><a href="#comment- <?php comment_ID() ?>" title=""<>?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('e','',''); ?></small>
    <?php comment_text() ?>

  2. Adjust the code to switch based on whether it’s a real comment.

    <?php if (get_comment_type() == "comment"){ ?>
    display code
    <?php } ?>

    This will now only show comments on your site. People can still trackback/ping your site (if your permissions allow this) and you’ll receive notification, but they won’t clutter up the comments section.

  3. If you want to show Trackbacks/Pingbacks on your site, mixed in with the comments, but in a different style, after the code in Step 2, add:

    <?php else { ?>
    display code
    <?php } ?>

    Remember that “display code” is replaced with the chunk of code in Step 1. Now, change this second lot of the display code to change the way Trackbacks/Pingbacks appear on your site. I have removed the body of the comment and just shows the link to their post:

    <li class="trackback" id="comment-lt;?php comment_ID() >">Trackback: <?php comment_author_link() ?></li>

    I’ve created a special class for my trackbacks so it can have its own style in the stylesheet (e.g. smaller font, different background color). If you decide to leave in the body of their post, my nicer trackbacks plugin will help get rid of the “[…]” bits if you want them gone.

Coming soon: I’m still working on an efficient way of being able to display your Trackbacks/Pingbacks entirely separately from your comments. One simple way would be to loop through your comments twice, once displaying the comments and the other to display the Trackbacks/Pingbacks. A better solution would be to loop through once and store the Trackbacks/Pingbacks for later display. Unfortunately most of the functions in WordPress don’t return a variable which can be stored, they echo the results directly…