Improving Trackback display

January 30, 2006

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() ?>
    </li>

  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…

Comments
  1. [...] cre8d design blog [...]

    WordPress Station &#187; Blog Archive &#187; Improving Trackback display, January 30, 2006

  2. [...] Improving Trackback Display In WordPress [...]

    Pig Pen - Web Standards Compliant Web Design Blog &#187; Blog Archive &#187; Improving Trackback Display In WordPress, January 30, 2006

  3. [...] Der Blog-Umbau geht weiter&#8230; Eben habe ich diese Idee aufgegriffen und die Formatierung von Trackbacks und Pingbacks gegenüber &#8220;normalen&#8221; Kommentaren leicht geändert. [...]

    Anderes Format für Trackbacks und Pingbacks &bull; {Bücher,Unterwegs,Rechner-Basteln,Kochen,&#8230;}, March 16, 2006

  4. That’s excellent - have seen a number of themes doing this kind of thing, but hadn’t found anywhere explaining it. Cheers!

    fouldsy, April 28, 2006

  5. I did something similar to this here:

    http://macstansbury.com/tutorials/hello-world.htm

    I used the IPAT plugin to move my trackback/pingbacks around, because I just don’t like them down in the comments (which are, for the most part, disabled).

    MacStansbury, August 3, 2006

  6. [...] 2. Nicer Trackbacks What this does is change the look of your trackbacks. Instead of having your trackbacks look like this &#8220;[…] Trackback link […]&#8221; they come out looking &#8220;Trackback link&#8221; &#8216;eh. Pretty nice touch to any WordPress website in my opinion. Also, you should look into fixing the output of your trackback display by changing the style they come out in, and seperating them. All thanks to cre8d. [...]

    Better WordPress Plugins at fybix.net &#8230;it could be worse&#8230;, September 1, 2006