BLOG

“I still suggest you call
this page 42Lab.
Works for both of us!”
- Joey

WordPress 101: Tips, Tricks and Hacks

Trackbacks and comments are two essential aspects of any WordPress blog. For the uninitiated, here is a short description of both trackbacks and comments:  

 

  • Trackbacks – Trackbacks are messages that are displayed along with comments in the comment list, every time another person links back to your original post. 
  • Comments – Comments are generally real people sharing their opinion about the content on the blog. The comment section of a blog can become a vibrant hub of human debate & discussion. Thus having computer-generated trackbacks in the middle might hinder the process of human connection.   

 

It is the default operation of WordPress to combine both comments and trackbacks. What if Separating the two can help you achieve a more organized look on your site. So, if you are looking for the wordpress tip that helps you separate them, you have come to the right place. Follow the steps below to do the same: 

 

Step 1: Find the following code in the comments.php file.

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

Paste the below code after it.

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

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

Step 2: Next look for the below code. 

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

Paste the below code before it

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

Step 3: After you find the above code, find the code below.

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

Paste the following below code before the above

 <?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 } ?>
42 works

Exploring the Future of Apps with Apple

Read Blog

42Works prioritizes your privacy. Learn how we collect, use, and protect your data.

Read Policy
42 works
Get 42Works Blog updates in your Inbox!

    Virginia United States 54.225.56.41 https://42works.net/separate-both-comments-and-trackbacks-wordpress/