our thoughts

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 */ ?>

your thoughts

Dennis Bullock

March 27 2006

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

[...] Rachel has a short but sweet run through on seperating Pingbacks / Trackbacks from the normal flow of the Wordpress comments loop. [...]

[...] Eben bin ich über einen Beitrag von Knut Karnapp auf eine Möglichkeit gestossen, Kommentare und Trackbacks in WordPress zu trennen. Ich hab mir den Code mal angeschaut und ein paar kleinere Veränderungen/-besserungen (Eigenlob stinkt … *Fenster aufmach*) vorgenommen. Unter anderem werden die Titel jeweils nur angezeigt, wenn überhaupt Kommentare bzw. Trackbacks vorhanden sind. (Ein Problem, mit dem grössere Blogs sich gar nie auseinandersetzen müssen.) Hier also meine modifizierte Variante: [...]

[...] Rachel Cunliffe geeft u de code om Pingbacks en Trackbacks netjes gescheiden te houden van de reacties. Bijkomend werd ook voorzien dat enkel de link verschijnt, in plaats van een gedeelte van de tekst. Een zeer mooie oplossing, die enkel wat copy/paste werk van u verwacht. Posted by Michael Filed in WP Hacks [...]

[...] Separating Pingbacks/Trackbacks from comments in Wordpress 2.0: Keywords: WordPress [...]

Jesse

April 5 2006

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

Rachel

April 5 2006

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

Bramus!

April 5 2006

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.

Trip

April 8 2006

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-admin\execute-pings.php (2.0 and above) and everything is better for me on that front.

[...] This one was also fairly simple to implement. I spent a bit of time Googling for ways to do this and ended up finding a couple of different techniques but the code on all of them was really untidy (sorry). I&#8217;m a big fan of beauty in code, not because I&#8217;m a geek (although I am) but because I find it makes the code easier to understand and maintain. [...]

[...] I didn&#8217;t have to search for a solution because I had already bookmarked this post by web designer Rachel Cunliffe. Just copy the code she posted in her blog post and paste it into your WordPress comment loop in comments.php. Replace the code in comments.php starting at &lt;?php if ($comments) : ?&gt; until &lt;?php endforeach; /* end for each comment */ ?&gt;, don&#8217;t replace the entire code in your comments.php or else you&#8217;d encounter errors. Posted by Max Limpag Filed in Blogs, Blog design [...]

fds

July 16 2006

sdsadfds
http://code.com
asd

subfor subforini

July 17 2006

gj 262fh 310

hg21gh

Elsewhere: Skype MSN Messenger Twitter Facebook