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

Separating Pingbacks/Trackbacks from comments in WordPress 2.0

March 27, 2006

Here’s some code below to enable you to separate pingbacks/trackbacks from comments in WordPress 2.0. Pingbacks/trackbacks are listed first, followed by comments in this example. It will also not show the excerpt for pingbacks/trackbacks and just show the link for these.

The basic idea is to loop through your comments twice – once displaying the pingbacks/trackbacks and once displaying the comments.

Copy and paste this code into your comments template – you’ll need to remove the old display of comments first.


<?php if ($comments) : ?>
<h3 id="trackbacks">Trackbacks/Pings</h3>
<ol class="commentlist">
<?php foreach ($comments as $comment) : ?>
<?php if (get_comment_type() != "comment"){ ?>
<li class="<?php echo $oddcomment; ?> smaller" id="comment-<?php comment_ID() ?>">
<cite><?php comment_author_link() ?></cite>
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
<br />
<p 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','',''); ?></p>
</li>
<?php /* Changes every other comment to a different class */
if ('alt' == $oddcomment) $oddcomment = '';
else $oddcomment = 'alt';
?>
<?php } ?>
<?php endforeach; /* end for each comment */ ?>
<h3 id="comments">Comments</h3>
<?php foreach ($comments as $comment) : ?>
<?php if (get_comment_type() == "comment"){ ?>
<li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
<cite><?php comment_author_link() ?></cite>
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
<br />
<p 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','',''); ?></p>
<?php comment_text() ?>
</li>
<?php /* Changes every other comment to a different class */
if ('alt' == $oddcomment) $oddcomment = '';
else $oddcomment = 'alt';
?>
<?php } ?>
<?php endforeach; /* end for each comment */ ?>

Creating a blog theme from scratch
WordPress 2.1 will have a spell-checker but…
  • http://dennisbullock.com Dennis Bullock

    Rachel, you are one a roll today! What has come over you?

  • Pingback: 5thirtyone | it’s not wheatgrass » Seperating Pingbacks / Trackbacks in Wordpress

  • Pingback: SilentWarrior.ch.vu » Kommentare und Trackbacks in WordPress trennen

  • Pingback: 8 Seconden » Blog Archive » Ping- en Trackbacks separaat houden van de reacties

  • Pingback: Synesthesia » Links Roundup for 2006-03-27

  • http://www.resiny.org Jesse

    the real question now is how to make it display seperately like in MT

    for instance, for this post it would be nice if instead of

    “Comments (6)”

    it said

    “Trackback (4) | Comments (2)”

  • http://www.cre8d-design.com/blog/ Rachel

    Yes, you could just loop through the comments and count up the number of trackbacks and comments.

  • http://www.bram.us/ Bramus!

    Improved version I’m using:

    Trackbacks/Pings

    " id="comment-"&gt;

    /

    comment_approved == '0') : ?&gt;
    Your comment is awaiting moderation.

    Comments

    " id="comment-"&gt;

    /

    comment_approved == '0') : ?&gt;
    Your comment is awaiting moderation.

  • http://www.bram.us/ Bramus!

    Minor improvement over at http://www.bram.us/2006/04/05/my-improved-pingbacks-trackbacks-comments-separation-for-wordpress-20/ ;)

  • http://www.soundtrip.com/ Trip

    Nice. Another related trackback/pingback issue with WordPress is how it gives precedence to pingbacks over trackbacks when posting. This provides constant frustration for me as the trackback will usually get rejected as a double ping. The problem is the trackback excerpt is usually what you want to show up as a comment on someone else’s site; pingbacks are more random.

    In fact those who blog on news will find that major newspapers in the US like the Washington Post will completely miss the mark if you pingback as opposed to trackback.

    I changed this behavior by flipping the order in wp-adminexecute-pings.php (2.0 and above) and everything is better for me on that front.

  • Pingback: Wordpress tips and tricks » Binary Moon

  • Pingback: Segregating trackbacks from comments in WordPress at Leon Kilat ::: The Cybercafe Experiments

  • Pingback: Nuudelisoppa » Separating Pingbacks/Trackbacks from comments in Wordpress 2.0

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