LolaTheriotHow to separate the trackbacks and pingbacks from comments?

Comments on blogs are often criticized as lacking authority, since anyone can post anything using any name they like: there’s no verification process to ensure that the person is who they claim to be. Trackbacks and Pingbacks both aim to provide some verification to blog commenting.

But having trackbacks, pingbacks and comments all mixed up in one place can get really messy and confusing. Let’s separate the trackbacks and the pingbacks from comments-
<strong><?php if ($comments) : ?>
<ol>
<?php foreach ($comments as $comment) : ?>
<li id=”comment-<?php comment_ID() ?>” class=’commentItem’>
<!– THE COMMENT LAYOUT –>
</li>
<?php endforeach; /* end for each comment */ ?>
</ol>
<?php endif; ?></strong>
Above we can see a stripped version of an ordinary comment loop which will show comments, trackbacks and pingbacks all in one place. Let’s change that.
<strong><?php if ($comments) : ?>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php
$commentType = get_comment_type();
if($commentType == ‘comment’) :
?>
<li id=”comment-<?php comment_ID() ?>” class=’commentItem’>
<!– THE COMMENT LAYOUT –>
</li>
<?php endif;/* end if comment check */ ?>
<?php endforeach; /* end for each comment */ ?>
</ol>
<?php endif; ?></strong>
get_comment_type is a function that returns “comment”, “trackback” or “pingback” depending what type the current comment is.
Now just copy paste the same code again and just change “if($commentType == ‘comment’)” toif($commentType != ‘comment’) which is the opposite of “==” and change the class from“commentItem” to “trackbackItem” so you can easily make different styles.
<strong><?php if ($comments) : ?>
<ol>
<?php foreach ($comments as $comment) : ?>
<?php
$commentType = get_comment_type();
if($commentType != ‘comment’) :
?>
<li id=”comment-<?php comment_ID() ?>” class=’trackbackItem’>
<!– THE PINGS LAYOUT –>
</li>
<?php endif;/* end if NOT comment check */ ?>
<?php endforeach; /* end for each comment */ ?>
</ol>
<?php endif; ?></strong>
Making the layout for pingbacks/trackbacks is very simple, there is only 1 function we are going to use, comment_author_link(). It just echoes the trackback/pingbacks link and that’s all we need.
<strong><li id=”comment-<?php comment_ID() ?>” class=’trackbackItem’>
<?php comment_author_link(); ?>
</li></strong>

Having trackbacks, pingbacks and comments all mixed up in one place can get really messy and confusing. Let’s separate the trackbacks and the pingbacks from comments-

<?php if ($comments) : ?>

<ol>

<?php foreach ($comments as $comment) : ?>

<li id=”comment-<?php comment_ID() ?>” class=’commentItem’>

<!– THE COMMENT LAYOUT –>

</li>

<?php endforeach; /* end for each comment */ ?>

</ol>

<?php endif; ?>

Above we can see a stripped version of an ordinary comment loop which will show comments, trackbacks and pingbacks all in one place. Let’s change that.

<?php if ($comments) : ?>

<ol>

<?php foreach ($comments as $comment) : ?>

<?php

$commentType = get_comment_type();

if($commentType == ‘comment’) :

?>

<li id=”comment-<?php comment_ID() ?>” class=’commentItem’>

<!– THE COMMENT LAYOUT –>

</li>

<?php endif;/* end if comment check */ ?>

<?php endforeach; /* end for each comment */ ?>

</ol>

<?php endif; ?>

get_comment_type is a function that returns “comment”, “trackback” or “pingback” depending what type the current comment is.

Now just copy paste the same code again and just change “if($commentType == ‘comment’)” toif($commentType != ‘comment’) which is the opposite of “==” and change the class from“commentItem” to “trackbackItem” so you can easily make different styles.

<?php if ($comments) : ?>

<ol>

<?php foreach ($comments as $comment) : ?>

<?php

$commentType = get_comment_type();

if($commentType != ‘comment’) :

?>

<li id=”comment-<?php comment_ID() ?>” class=’trackbackItem’>

<!– THE PINGS LAYOUT –>

</li>

<?php endif;/* end if NOT comment check */ ?>

<?php endforeach; /* end for each comment */ ?>

</ol>

<?php endif; ?>

Making the layout for pingbacks/trackbacks is very simple, there is only 1 function we are going to use, comment_author_link(). It just echoes the trackback/pingbacks link and that’s all we need.

<li id=”comment-<?php comment_ID() ?>” class=’trackbackItem’>

<?php comment_author_link(); ?>

</li>

http://www.all1Press.com

http://www.all1martpro.com

Tags: , , , ,