WordPress Tips: Separate Comments and Trackbacks

by 6 years ago

separate comments and trackbacks

By default, in most of the WordPress themes you might have noticed that there are both comments and Trackbacks and they are together. Its means both are displayed in the same list. It becomes difficult for visitors to distinguish between comments and trackbacks.

To make your blog more organize you should separate comments from trackbacks. So that your commenter can have a clear picture What are the comments and What are the trackbacks.

Separating comments and trackbacks is not to difficult works, here in this article i am going to explain  “How to Separate Comments and Trackbacks?” . By doing some editing in your comments.php you can separate your blog’s comments and trackbacks.

Separate Comments and Trackbacks

Before start editing to your comments.php file , first backup it. so that you can do safe editing to your blog (To use this tips you must have you own separate domain for your blog, not of www.wordpress.org  ).

Go to your WordPress dashboard -> Appreanaces -> Editor -> Comments.php

Step 1.

Find (find you the following code in your comments.php):

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

Place after (paste the follwoing code after above code):

<?php $comment_type = get_comment_type(); ?>

<?php if($comment_type == ‘comment’) { ?>

Step 2.

Find (find you the following code in your comments.php):

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

Place after (paste the follwoing code after above code):

<?php } else { $trackback = true; } /* End of is_comment statement */ ?>

Step 3.

Find (find you the following code in your comments.php):

<?php else : // this is displayed if there are no comments so far ?>

Place after (paste the follwoing code after above code):

<?php if ($trackback == true) { ?>

<h3>Trackbacks</h3>

<ol>

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

<?php $comment_type = get_comment_type(); ?>

<?php if($comment_type != ‘comment’) { ?>

<li><?php comment_author_link() ?></li>

<?php } ?>

<?php endforeach; ?>

</ol>

<?php } ?>

Done, now update you blog and browse it to seen the changes. By default your trackbacks are appear after you comments, if  you want that your trackbacks come before comments you can add <div> tag in your Stylesheet.

This is all for separate comments and trackbacks. If you have any other tricks to do the same task, feel free to leave a comment.

Comments

Load More