Subscribe Via RSS

3268 Subscribers

Subscribe Via RSS
Subscribe Via Twitter

Followers

Subscribe Via Twitter
Seperating Trackbacks & Pingbacks

April 4th, 2009 in Wordpress Tutorials by Richard Carpenter

Seperating Trackbacks & Pingbacks

1 Star2 Stars3 Stars4 Stars5 Stars8 Votes, Rating: 3
Loading ... Loading ...
About The Author

About The Author: Richard Carpenter

Hi im Richard Carpenter im a freelance web and graphics designer from England. I am also a regular Blogger, Tutorial Writer, and owner of HV-Designs. You can follow me on twitter HERE. You may also view my portfolio HERE.

 

Richard Carpenter has written 331 posts.

Hello, welcome to another tutorial by hv-designs. Today we’ll be diving into wordpress again looking at seperating our comments and our trackbacks.

Most blogs i visit or have seen dont bother to seperate there comments and tracksbacks, personnally i think it looks better and more orgainised. It can be achived with minium effort and very little code. In todays tutorial il be seperating our trackbacks and comments using the “mywordpress theme” tha we previously created a couple of days ago. Open up your comments.php file in dreamweaver or notepad. The file should be located in the theme directory.

Step1

Once open locate the line “php foreach $comments as $comment”.

Step2

After this line paste this snippet of code.

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

Your code should now look like this.

Step3

Scroll down and locate the end of comment loop. “php endforeach; /* end for each comment */”.

Step4

Just before the code above we need to end our “is comment statment”. Which looks like this.

<?php } /* End of is_comment statement */ ?>

The code should look like this.

Step5

What does all this code do i here you shout????? Basically the code will seperate all your trackbacks and pingbacks from the main comments loop. This will allow us to add a second comments loop to the comments file to display the trackbacks and pingbacks only.

Locate this snippet of code inside your comments.php file.

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

Step6

Just before it add this code.

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

Step7

If you are using the “mywordpress theme” change the H3 tag from H3 to H1 or H2. Thats it all done, the code above can then be styled as you wish, its not that different from when we styled our comments.php file in the “my wordpress theme tutorial”. If you liked this tutorial please subscribe to our twitter and RSS feeds. Thanks for reading, till next time.

Be Part Of The Community!

Become part of the hv-designs community.

Subscribe Via RSS or Follow Us On Twitter.

Subscribe Via RSS Follow Us On Twitter

13 Responses to “Seperating Trackbacks & Pingbacks”

  1. Gary says:

    Nice good thing to know thank you.

  2. Very good work
    Thanks

  3. cruwdy says:

    nice :D
    but I got a question, why do you use this:
    1. Trackbacks
    2.
    3.
    4.
    5.
    6.
    7.
    8.
    9.

    and not just
    1. Trackbacks
    2.
    3.
    6.
    7.
    9.

    ??
    greetz,
    cruwdy

  4. ADMIN says:

    @CRUWDY:

    if you look at the last snippet of code you will see its wrapped in a OL (ordered list) if you dont want it to display like that then you can change it ;)

  5. Swen says:

    I’m not exactly sure what this does.. Can anyone explain?

  6. ADMIN says:

    @SWEN:

    in wordpress on certain posts you get pingbacks and trackbacks, these are displayed within the comments area along with the comments. A trackback/pingback looks very similar to a comment, but its not a comment. With this tutorial you can split them up, so all the comments are togther and all the trackbacks and pingbacks are together, giving your comments area a much neater appearance

  7. Dan says:

    Great tutorial, thanks for submitting it… just an FYI, it’s “Separating” not “Seperating” :)

  8. PelFusion says:

    I saw separation of comments and trackbacks on smashingmagazine and i was just wondering to do it on my blog and saw this tutorial

    thanks

  9. Arco says:

    Nice post. This is very intresting. I’m doing a new blog, and could be using this..

Leave a Reply