cre8d design - clean, clear, creative websites
  • Latest
  • Highlights
  • Discussions
  • Blogging
  • Design
  • Ebooks / Books
  • Social Media
  • Personal
  • About
  • Portfolio
  • Services
  • Blog
  • Contact
  • Twitter
  • Facebook
  • RSS

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…

Improving the readability of large numbers of comments
WordPress 2.0 bug fixes
  • Pingback: WordPress Station » Blog Archive » Improving Trackback display

  • Pingback: Pig Pen - Web Standards Compliant Web Design Blog » Blog Archive » Improving Trackback Display In WordPress

  • Pingback: Anderes Format für Trackbacks und Pingbacks • {Bücher,Unterwegs,Rechner-Basteln,Kochen,…}

  • http://www.fouldsy.com fouldsy

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

  • http://macstansbury.com MacStansbury

    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).

  • Pingback: Better WordPress Plugins at fybix.net …it could be worse…

Hi, I'm Rachel Cunliffe!

Looking for a blog designer, Wordpress expert, website designer, or want to find out how I can help you? I'd love to hear from you.

Email:
rachel@cre8d-design.com
Phone:
(US) 646 233 3046
(NZ) 027 3833 746
Skype:
rachelcunliffe

Keep updated

Get blog posts via email

Follow @cre8d