preloader LOADING

42Works Blog

Posted on December 21, 2019

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

Leave a Comment:

Your email address will not be published.

para glider
Have a Project ?
We are just as excited

Contact Us

about your Idea
My name is
& I'm interested in discussing about
for my project
. You can email me at
or ring me up at
.

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