Pro Blog Design

Better Looking Blogs Grow Faster

First time? Start here.

Footsteps in the sand. Trackbacks are the messages displayed in the comments list whenever another blog links back to one of your posts. Many blogs disable trackbacks, but not all.

If you use trackbacks on your blog, it is best if they are not mixed with the comments. The comments are a conversation between between real people. Having machine-generated links in the middle of that will only serve to disrupt the conversations.

The method described here will lift out all of the trackbacks, and then display them as a numbered list after the list of comments is finished. Once you have this done, customizing the trackbacks to appear however you want them to is simple.

And thanks to Gary, the Trackbacks header will only appear if the post has a trackback to show.

NB - This method will only work for WordPress users. Sorry guys!

How To Separate the Trackbacks

Open comments.php, and search for the following line:

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

After it, paste the following:

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

Now look for:

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

And before it, paste:

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

That means that your list of comments will continue to display as normal, but without any trackbacks or pingbacks. Now we will add a second comments loop for the trackbacks.

Look for the following line:

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

And before it, paste this: (The "Trackbacks" title line can be deleted if you don't want a heading to be shown)


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

Of course, this is all only helpful if you actually use trackbacks, and there are some good reasons for either side of that debate. Do you use trackbacks on your blog? Why?

Discussion on This Article

  1. goldfries
    September 18th at 11:56 am GMT
    Comment #1

    Strange, I get notified about trackbacks and I do see them on my WPadmin Comments section but it doesn't appear on my posts' comments section even without any modifications.

    Did I miss out something?

  2. Michael Martin
    September 18th at 12:03 pm GMT
    Comment #2

    Your theme may already be set up to block them out. :)

    If they appear in your comments area, it does mean that they're enabled and have been saved as post comments.

  3. redwall_hp
    September 18th at 12:52 pm GMT
    Comment #3

    I've been meaning to do this for a while now, but I haven't decided whether I should put trackbacks above or below comments.

  4. Michael Martin
    September 18th at 1:02 pm GMT
    Comment #4

    It depends on the blog Matt, but on Webmaster Source you follow each post with a list of related posts. You wouldn't want to have that followed immediately by another list of links.

  5. sarahG
    September 18th at 1:19 pm GMT
    Comment #5

    I used to kill trackbacks due to them being 99% spam, however I switched them back on as I think it's good to have a link to other posts mentioning yours. Trouble is I've broken it all now and they don't seem to appear!

    Separating them is a good idea. I've seen it in the past and it does make things flow better :)

  6. Liberty and New Creation
    September 18th at 2:01 pm GMT
    Comment #6

    Hah. I was JUST wondering how to do this after stumbling across another blog that did so.

    Thanks for the practical advice. You've once again confirmed that I need to stay subscribed to your feed.

  7. Michael Martin
    September 18th at 2:43 pm GMT
    Comment #7

    Sarah - Morally I do think it's nice. I don't use them here though because they aren't necessarily links that I recommend. If there is going to be a list of links, it should be a hank-picked list that I have chosen specifically for my readers. (I suppose that's more of a problem for smaller blogs, like this one. Larger blogs probably get a lot nicer trackbacks! xD )

    Liberty - Yes! You must always stay subscribed. For ever and ever and ever! :p

  8. Slevi
    September 18th at 5:09 pm GMT
    Comment #8

    Nice little guide :), since I don't get many trackbacks I don't think it'd really matter in which way I display them to begin with though :P. By far the most avid trackbackers for my blog are spammers, hehe. Those are nicely being blocked from public of course.

    But I'll keep this in mind for if it ever would occur that I would start getting a lot of them ;).

  9. Michael Martin
    September 18th at 5:13 pm GMT
    Comment #9

    I hope that that will be the case someday Slevi. For 2 reasons. ;)

  10. David Hopkins
    September 18th at 10:46 pm GMT
    Comment #10

    WordPress is so messy with its PHP in the HTML. I wonder how long it will take for a new higher grade blogging software to knock them of their spot?

  11. Michael Martin
    September 18th at 10:51 pm GMT
    Comment #11

    I like that aspect of it David. It gives you complete control over the design through only the templates files. Very rarely have I had to touch the actual WP's files. At the very least, it makes upgrading easy.

  12. Connor Wilson
    September 19th at 12:24 am GMT
    Comment #12

    I use a much more complicated way of doing this, but it allows me to count them separately and run totally different loops for them.

    My comments.php is huge because of all this :P

  13. Slevi
    September 19th at 12:43 am GMT
    Comment #13

    @David: Probably very long, the majority of the users simply couldn't care less about messy code. Living proof of that is mySpace, it has even the shittiest page source and I highly doubt their backend is much better but meanwhile it is one of the best visited sites in the web.

    As inefficiently wordpress might be doing a couple of things currently, the amount of people actually caring about it is just too small to make a change.

  14. Michael Martin
    September 19th at 5:07 pm GMT
    Comment #14

    Connor - You can do that with this code as well. I originally set it up on this blog, where we do count the comments, and it's already running two seperate loops.

    Of course, the nice thing about coding is that there are always a few ways to achieve the same goal. ALl are equally valid. :D

  15. paidtwice
    September 20th at 12:46 am GMT
    Comment #15

    Yay it worked! Thank you!

    I never managed to get the author coded different color one to work (for some reason my email address isn't recorded when I myself comment? hmm) but this one worked :). Thanks!

    One small question: if I wanted it to say something innocuous like "Trackbacks:" before the list of trackbacks, where would I write that (and how) in the code to do that?

  16. Steven Snell
    September 20th at 2:33 am GMT
    Comment #16

    I like seeing them separated on other blogs, and I've been thinking about doing it one mine. I just haven't made the time to do it, so thanks for the reminder.

  17. Michael Martine with an E
    September 20th at 3:22 am GMT
    Comment #17

    One thing I like about using the Sandbox theme as a basis for custom WordPress themes is that separation of comments and trackbacks/pingbacks is built into it.

    I like to reward commenters and linkers, so I have removed "nofollow" from my blog and feature a recent trackbacks list on my home page (as well as recent comments). I definitely believe in showing trackbacks!

  18. kristarella
    September 20th at 9:24 am GMT
    Comment #18

    Nice! I've seen this once or twice on blogs and thought it was kind of cute.
    Perhaps I will do this on my blog, even though I get very few trackbacks!

    Michael Martine with an E - I started making a theme based on Sandbox and found the code to be so bloated and messy that I didn't know where to start! How do you find working with it?

  19. Michael Martin
    September 20th at 9:39 pm GMT
    Comment #19

    paidtwice - Glad it helped! Sorry to hear the author one didn't work so well. The code does work, but I may have been a little grey with some of the instructions. I'll just have to be more clear in future!

    To add the "Trackbacks" heading, look for the last section that you pasted in, beginning with:

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

    Before that, paste the following:

    <h3>Trackbacks</h3>

    That will do it. :)

    Steven - No problem. :)

    Michael - First off, I love the name! Secondly, it's a nice thing to show trackbacks like that. I have nofollow removed here, but not the trackbacks. I'm a little worried about their impact on SEO, and that they mightn't always be overly relevant links. :(

    kristarella - It's always an option! There's no need to do it, especially if you aren't showing trackbacks at the minute anyway, but if you are, I think it's a good way of doing it.

  20. paidtwice
    September 20th at 10:39 pm GMT
    Comment #20

    Thanks! That worked great!

    No worries on the author color comment thing, I am not skilled at coding... anything. :) I may have messed something up. I intend on trying again :)

    Future topic suggestion.... how you make your columns start lower and extend your header on that one part to put that quote in. That would rule (if I could figure it out that is lol).

  21. Michael Martin
    September 20th at 11:18 pm GMT
    Comment #21

    Glad it worked! :)

    Thanks for the idea, but it would be a little harder to explain. It's actually quite easy to do (For a coder that is), but because every theme is so different, it wouldn't be as easy as copying&pasting. You would need a basic understanding of CSS I'm afraid, to work out the specifics for your own theme. :( (I do plan on writing some articles that would give you that basic understanding in the future, but not just yet!)

  22. goldfries
    September 20th at 11:38 pm GMT
    Comment #22

    Arrggh. I just found out it appeared in one of my post. :) This post of yours is going to be useful. ;)

  23. Michael Martin
    September 20th at 11:43 pm GMT
    Comment #23

    Well, it will if it works! ;)

    *fingers crossed*

  24. Moses Francis
    September 21st at 8:50 am GMT
    Comment #24

    I totally agree with you, it's always best to seperate trackbacks and human comments.

  25. Laarni
    September 21st at 3:16 pm GMT
    Comment #25

    I'm going to try this. :) Thanks.

  26. Michael Martin
    September 21st at 4:58 pm GMT
    Comment #26

    Moses - Agreed. Combining them only leads to confusion and annoyance.

    Laarni - Glad to hear it. Good luck! (Let me know if you have any problems. :) )

  27. JHS
    September 22nd at 3:01 am GMT
    Comment #27

    Hi there: I started to implement this and then discovered that there is verbiage in my theme indicating that pings/trackbacks and comments are already separated. But the trackbacks are not appearing. How can I tell if they have been disabled and how do I allow them again? I am getting e-mail notifications of them and they are included in my total comment count, but they don't actually appear on my site.

    Thanks.

  28. kristarella
    September 22nd at 7:28 am GMT
    Comment #28

    You're using a modified Copyblogger - I found that code in my theme too (also Coppyblogger). I don't think that the function separating them is activated by default in CB - from Chris's comment about it. Are you sure that your trackbacks are not showing up as comments? Perhaps they can be excluded from the admin?

    In light of the function not being active you could probably still use this code and leave that over code alone (I'm thinking of doing that).

  29. Suzanne of New Affiliate Discoveries
    September 22nd at 7:41 am GMT
    Comment #29

    Wow, great tip, I was just looking into how to do this. you'll definately be getting a trackback from me in this weekends Sunday Seven edition!

  30. JHS
    September 22nd at 8:05 am GMT
    Comment #30

    Kristarella: I love what you've done with the CB theme!

    Unfortunately, this won't work for me because the language referenced is not in the comment.php file, so I don't know where to start to implement this work around.

    I'm sure . . . my trackbacks and pings are definitely not showing up at all except in my dashboard.

    Thanks.

  31. kristarella
    September 22nd at 1:09 pm GMT
    Comment #31

    Thanks JHS, I appreciate the compliment :)

    I think I found the code - look for:
    <?php $count_pings = 1; foreach ($comments as $comment) { ?>
    and
    <?php $comment_number++; } /* end for each comment */ ?>

    They should be the places that you need to put code after and before respectively, according to Michael's instructions. I haven't tested it, so make sure you back up your comments.php incase it doesn't work.
    The 'php else' code that you place the trackback code before is the same.

    p.s. Sorry in advance if that code doesn't show up properly - I never know how WP processes these things!

  32. Michael Martin
    September 22nd at 1:51 pm GMT
    Comment #32

    JHS - If they had been disabled, you wouldn't get any notification of them. Let me know if Kristarella's advice works for you. If it doesn't, I'll try out the copyblogger theme myself and see what needs to be done.

    Kristarella - Thanks for helping out! :D

    Suzanne - Thanks! Hope it works out for you.

  33. kristarella
    September 22nd at 1:57 pm GMT
    Comment #33

    No worries :)
    I'm trying out your code right now with the code that I just mentioned and it seems to be working - just needs a bit of styling. However, my trackbacks were showing up as comments, so I'm not sure what's happening there.

  34. kristarella
    September 22nd at 2:14 pm GMT
    Comment #34

    Oops - unclear comments - I meant my trackbacks were showing up before, so I don't know if what I've done to my file will work for JHS.
    Anyway, it's all working nicely. Thanks for the instructions!

  35. Michael Martin
    September 22nd at 4:16 pm GMT
    Comment #35

    No problem. If they were showing up before then the code above should definitely work, if you've tweaked it for Copyblogger. :)

  36. JHS
    September 22nd at 4:45 pm GMT
    Comment #36

    I tried placing the code where Kristarella suggested.

    You can see the result here:
    http://www.jhsiess.com/hereslo.....-on-track/

    You see 5 comments there.

    But if you go to the homepage, you will see that under the post excerpt (it is the last post on the front page), the verbiage is "17 Comments."

    I use the Better Comments Manager plugin and I have a total of 17 comments, pings and trackbacks there.

    So they are coming in, but are not showing up.

    Thanks for any assistance you can provide!

  37. JHS
    September 22nd at 4:49 pm GMT
    Comment #37

    Kristarella: Would you be willing to share your comments.php file with me? If you e-mail it to admin@jhsiess.com, I can compare your file with mine and perhaps figure out what's going on.

    Thanks.

  38. kristarella
    September 23rd at 2:10 am GMT
    Comment #38

    I see what you mean JHS, that's weird the 17/5 comments thing. There is a chance that a plugin is causing that Even though the plugin doesn't really have anything to do with trackbacks. How much do you actually use that plugin?
    I can email you my comments file. No problem.

  39. paidtwice
    September 23rd at 5:26 am GMT
    Comment #39

    I use the Better Comments Manager too and it doesn't hide my trackbacks. But I run a different theme so it may not matter. lol

  40. Michael Martin
    September 23rd at 9:42 pm GMT
    Comment #40

    Just wanted to say thanks again Kristarella, and paidtwice now. It's good of yous to help out. :)

  41. Tay
    September 24th at 7:47 am GMT
    Comment #41

    Thank you, thank you, THANK YOU! :D I've just implemented this on my blog and it worked perfectly. I appreciate you sharing this advice.

  42. Michael Martin
    September 24th at 12:05 pm GMT
    Comment #42

    No problem Tay. Glad it worked for ya. :)

  43. pablopabla
    September 28th at 4:23 am GMT
    Comment #43

    I just got back from vacation and am now catching up on your articles. Thanks Michael! I've pasted the codes and they are working perfectly. I was wondering whether it is possible to put a custom message immediately above the Trackbacks? I tried that but this message also comes up in posts without trackbacks.

  44. kristarella
    September 28th at 5:23 am GMT
    Comment #44

    Hey pablopabla,
    I'm not great with php, but I think I have what you're looking for.
    <ol class="trackbacks">
    <?php foreach ($comments as $comment) : ?>
    <?php $comment_type = get_comment_type(); ?>
    <?php if($comment_type != 'comment') { ?>
    <h3>Trackbacks ↓</h3>
    <li><?php comment_author_link() ?></li>
    <?php } ?>
    <?php endforeach; ?>
    </ol>

    In the h3 tag I've got my Trackback title, which should only show up when there are trackbacks (because it's after the "if" thing. You could put whatever you want there.

  45. pablopabla
    September 28th at 10:41 am GMT
    Comment #45

    Thanks Kristarella.

    However, I notice that the "Trackbacks" wording repeats itself for each and every Trackback on the posts. :O

  46. kristarella
    September 28th at 11:37 am GMT
    Comment #46

    Bother! You are absolutely right. I actually have so few trackbacks that it was difficult to find a post with 2 on it! (I guess I'm hoping for more in the future :P)

    In that case, I too would like an answer to the question!

  47. Michael Martin
    September 28th at 5:38 pm GMT
    Comment #47

    Hey pablopabla! Nice to see you again. :)

    I'm going to add that into the post now. Another commenter asked the same question. You can read my answer here in the meantime. :)

    Kristarella - Incase you're interested: the problem with yours is just that the foreach(... line is the start of a loop. Everything between that an endforeach is repeated for every item (trackback) on the article. :)

  48. Brian Purkiss
    September 30th at 4:24 pm GMT
    Comment #48

    That's a good idea!
    But, do you have an example?
    A screenshot of the results would be very helpful in deciding if I'm going to use that.

    (I most likely will, but a screenshot will be helpful)

  49. Michael Martin
    September 30th at 4:36 pm GMT
    Comment #49

    Yep, the articles on SkellieWag display trackbacks like this. :)

  50. Brian Purkiss
    September 30th at 7:19 pm GMT
    Comment #50

    Thanks so much!
    I am going to use that now!

  51. Michael Martin
    September 30th at 7:23 pm GMT
    Comment #51

    No problem. Let me know if you have any problems. :)

  52. pablopabla
    October 1st at 7:20 am GMT
    Comment #52

    Thanks for the tip Michael. However, is it possible to further tweak it so that the customisation (the line between the ) does not appear at all when there are no trackbacks to a post? At the moment, the customisation appears in all posts.

    :D

  53. Gary
    October 19th at 3:48 pm GMT
    Comment #53

    Thanks for the great tip on trackbacks.

    To have the trackbacks showing only if there are some is quite easy change to make...following your original instructions, instead of this:

    Do this:

    And instead of this:

    Trackbacks

    Do this:


    Trackbacks

  54. Michael Martin
    October 19th at 5:35 pm GMT
    Comment #54

    Hey Gary - Thanks for trying to help out, but there's no code in your comment. Did something go wrong? :(

  55. Gary
    October 19th at 6:13 pm GMT
    Comment #55

    Hey Michael

    Hmm, seems to have gone wrong. No matter, see http://www.osworld.biz/1004/se.....-comments/

    Cheers, Gary

  56. Michael Martin
    October 19th at 6:25 pm GMT
    Comment #56

    Looks good now, thanks. :)

  57. Forrest
    November 21st at 5:00 am GMT
    Comment #57

    This is fantastic ... thanks so much for the tip! I've seen a lot of blogs doing this and always wondered how. I agree they interrupt the flow of conversation, but I've been told by people smarter than I am that trackbacks are helpful.

    One question, though, since I don't know that much PHP ... how would I make the text Trackbacks and the ordered list underneath it only show up when there are more than zero trackbacks?

  58. kristarella
    November 21st at 5:14 am GMT
    Comment #58

    Hey Forrest - this is a really great solution. I agree that trackbacks interrupt the comversation.

    See Gary's comment for the solution to that issue. I'm using his code on my blog.

  59. Michael Martin
    November 21st at 10:33 pm GMT
    Comment #59

    Hehe - You must be subscribed to this post Kristarella. Thanks for helping Forrest out. :)

  60. Forrest
    November 27th at 2:50 am GMT
    Comment #60

    I guess I should have read all of the comments first...! Before I came back and saw that, I implemented more or less the same thing in javascript, but this is a cleaner solution overall. So for the second time thanks!

  61. Michael Martin
    November 27th at 9:02 pm GMT
    Comment #61

    lol - I wonder if Kristarella will pop in to say "Welcome" :D

  62. kristarella
    November 27th at 10:19 pm GMT
    Comment #62

    I usually only come back when someone has an issue that they're trying to solve ;)

  63. Michael Martin
    November 27th at 11:20 pm GMT
    Comment #63

    Fair enough. I'm just glad you do. :D

  64. Nathan Chapman
    January 4th at 1:18 am GMT
    Comment #64

    Thanks for this tip, it's helped :)

    One thing though. My site keeps on making trackbacks to itself whenever I link back to another article of mine. Can I stop it from doing this? I'm using WP 2.3.2

  65. Michael Martin
    January 4th at 5:10 pm GMT
    Comment #65

    Nathan,

    I've disabled trackbacks here, so I can't say anything for certain, but this plugin looks good. If you try it, let me know if it works please. :)

  66. Nathan Chapman
    January 5th at 3:02 am GMT
    Comment #66

    Thanks for the link Martin, and yes the plugin does work, for all you people out there with the same problem. :)

  67. Michael Martin
    January 5th at 12:50 pm GMT
    Comment #67

    Nathan, glad to hear it and thanks for letting us know (I've bookmarked it now ;) )

  68. Forrest
    January 5th at 8:13 pm GMT
    Comment #68

    WordPress automatically sends itself trackbacks, and auto-publishes them.  I go back and delete them manually;  occasionally I'll actually want to let one remain.If a reder discovers my blog through an old post, [self] trackbacks are a good way to connect that post to other specific ones on the same subject, or that refer to it in a meaningful way.  My post on The Gorge is a good example.Food for thought, anyway...

  69. Michael Martin
    January 5th at 9:14 pm GMT
    Comment #69

    Forrest, that would work as well, and it does give you more control over the process, but I think that having to manually delete a link every time I interlink my posts would bug me, and probably put me off interlinking. :( (Though perhaps encourge me to link out more instead?)

  70. Forrest
    January 6th at 6:01 am GMT
    Comment #70

    My blog gets scraped a bit.  It sounds like that's been more of a problem either in the past or for other people, but it's at least an annoyance.In a recent interview, Matt Cutts said that when Google sees the same content showing up on ten pages on ten different sites, but nine of them link back to one that doesn't link out to any of the others, they assume it's scraped, and transfer any pagerank the copies might attain to the original.  ( He wasn't clear about whether you need to link to the specific page or just back to the domain the original was published on? )It's neighborly to link out, but I wouldn't let the trackbacks stop me from linking back to earlier posts.

  71. Michael Martin
    January 6th at 12:07 pm GMT
    Comment #71

    Forrest, it sounds like the sort of thing that Google would be able to do (How hard can it be to catch on that a site is a splog?). They're also becoming a lot more consious of the time that content showed up on certain sites, so if you publish an article first, and then splog rips it a few days later, Google should have found it on your blog first hopefully. That might stand for something.

    And if you're willing to take the time, then the manual way is great. I'm just a little lazy I suppose. With WP in the backend, I like to automate as much as possible. :D

  72. kristarella
    January 6th at 11:49 pm GMT
    Comment #72

    Well, I got a little lost in this conversation. I think I got the gist though... I've had a few of those slightly dodgy trackbacks. Where the blog looked like nothing more than copying sections of text with a link to the author. One of them was extremely dodgy and caled me "americanshopper" rather than "kristarella"!

    Should I delete all trackbacks that don't look useful to me?

  73. kristarella
    January 6th at 11:52 pm GMT
    Comment #73

    BTW, not sure about this WYSIWIG comment editor. It's a good idea, but it didn't keep some of my line breaks just then, and it seems to insert some extra code that I get as plain text in emails when subscribed to comments.

  74. Michael Martin
    January 7th at 1:02 am GMT
    Comment #74

    Kristarella - Yes, I'd delete the spammy trackbacks. Linking out to a spammy site is going to annoy your readers if they click the link, and could hurt you in Google (If it associates you with that spam site).

    But I love the WYSIWYG! I haven't had any problems with it yet (Bar some teething problems in IE7, which should now be fixed).

    The line-breaks you lost, were they multiple line breaks in a row? If so, I think that was WordPress, not the editor. :(

  75. kristarella
    January 7th at 1:34 am GMT
    Comment #75

    Haha, ok.

    I'd just hit enter a couple of times, I don't know what WP usually inserts there.

    See how it goes this time. ;)

    Edit: oh, it didn't work. I've added all those breaks manually. Normally hitting enter adds a break or ends a paragraph, unless you turned it off. Curious. Maybe just my browser.

  76. Tip Diva
    January 7th at 5:20 am GMT
    Comment #76

    Spectacular - works great! Thank you!

  77. Michael Martin
    January 7th at 10:37 am GMT
    Comment #77

    Kristarella,

    Hmm, what browser are you using? I'll try it out as well.

    Tip Diva - Glad it worked for you. :)

  78. kristarella
    January 7th at 11:45 am GMT
    Comment #78

    I was using Camino the last couple of times.Now I'm trying Safari.

  79. Michael Martin
    January 7th at 12:21 pm GMT
    Comment #79

    I'm in Safari now. Let's see how it goes.

    I don't have Camino though (Windows user). :(

    EDIT - It left out the line breaks on me as well. I'll head over to the support forums to see if anyone else has had this problem.

  80. Michael Martin
    January 7th at 12:30 pm GMT
    Comment #80

    And now that I've added more code;

    Will

    This

    Work? :)
    (Sorry about the emails Kristarella! xD )

    EDIT - The line breaks worked for me now. What about you?

  81. cekay
    January 20th at 3:11 pm GMT
    Comment #81

    Thank you very much for this information. Found it via google cause it's annoying to have a trackback look like a comment. your hack works exactly as i wanted it!

  82. Corrina
    January 29th at 7:33 am GMT
    Comment #82

    THANK YOU for this post! It was making me crazy that my trackback's were coming in as comments. Now that's all fixed. :-)

  83. Michael Martin
    January 29th at 1:14 pm GMT
    Comment #83

    Glad it worked for yous :)

  84. Millionaire Money Habits
    February 1st at 5:45 pm GMT
    Comment #84

    Looks great, but I get a W3.org invalid page error. Do you know how to fix this?
    end tag for "ol" which is not finished
    Most likely, you nested tags and closed them in the wrong order. For
    example <p><em>...</p> is not acceptable, as <em>
    must be closed before <p>. Acceptable nesting is:
    <p><em>...</em></p>

    Another possibility is that you used an element which requires
    a child element that you did not include. Hence the parent element
    is "not finished", not complete. For instance, in HTML the <head> element
    must contain a <title> child element, lists (ul, ol, dl) require list items (li,
    or dt, dd), and so on.

  85. Millionaire Money Habits
    February 1st at 6:44 pm GMT
    Comment #85

    to add to the above, it seems to only validate if there are either no comments and no trackpacks, or if there are both comments and trackbacks.If there are one and not the other on the post, then I get the invalid error above.

  86. kristarella
    February 2nd at 1:15 am GMT
    Comment #86

    Millionare Money Habits - are you sure you're implementing the code correctly?

    I'm using this method and I don't get validation errors. Here's the output from a page that's got lots of trackbacks. There are errors, but they're all for a plugin that has nothing to do with this.

  87. kristarella
    February 2nd at 1:17 am GMT
    Comment #87

    By the way, dig the new sidebar Michael. It's really useful and easy to read.

  88. Michael Martin
    February 2nd at 12:38 pm GMT
    Comment #88

    Millionaire Money Habits - The problem is that the original code put out some code, regardless of whether the post had any trackbacks or not.

    I've updated it now though, thanks to Gary, with a few new lines that will fix that. The easiest way to fix your code would be delete the changes you made the other day (Sorry!), and then run through the post again.

    Sorry for the hassle. I should have made that update a while back :(

  89. Michael Martin
    February 2nd at 12:39 pm GMT
    Comment #89

    And Kristarella, thanks. There'll be a post up about it in a day or 2. :D

  90. Millionaire Money Habits
    February 2nd at 3:33 pm GMT
    Comment #90

    Thanks Michael. I made the changes, but still get the W3C invalid response on posts that only have trackbacks and now comments.

    Post that only have comments and no trackbacks are validating now, so there's progress.

    Thanks!

  91. Michael Martin
    February 2nd at 8:56 pm GMT
    Comment #91

    MMH - Ahh yes, that problem would remain. There's no easy way around that one. The only method I can think of is pretty messy and would involve running through all of the comments twice, just to check if there were any comments.

    How important is the validation to you? It can't be very often that you get a post with trackbacks but no comments, and the fix for those occasions would be putting on needless extra server load in every page. :(

  92. Millionaire Money Habits
    February 2nd at 9:06 pm GMT
    Comment #92

    I guess it's no biggie - i'm just being anal in having my pages validate for SEO purposes.I guess the easy thing to do would be to just add a comment to those posts. Thanks for all the help and quick replies!

  93. Michael Martin
    February 2nd at 11:33 pm GMT
    Comment #93

    SEO purposes? I don't think that W3C valid code will have any impact on your SEO.

    It might impact it if the errors were so bad that the search engines couldn't make sense of your page, but with a tiny error like this, there's nothing to worry about. :)

  94. Millionaire Money Habits
    February 2nd at 11:40 pm GMT
    Comment #94

    Oh, ok. I didn't realize that. I thought it mattered for SEO. Thanks again!

  95. Michael Martin
    February 3rd at 12:47 am GMT
    Comment #95

    No problem. See you around. :)

  96. milo
    February 4th at 11:37 am GMT
    Comment #96

    Hum, I guess what comes around will come around.

    Coincidense...

  97. Ramil
    March 1st at 6:34 pm GMT
    Comment #97

    Thanks for the nice tip. I will implement this on my blog design.

  98. Michael Martin
    March 2nd at 12:15 am GMT
    Comment #98

    milo,
    Sorry, I didn't see your message before. But ack well, this code has been spread about in plenty of places by now. :(

    Ramil,
    No problem. Glad ya found it useful. :)

  99. Merci
    March 8th at 7:33 pm GMT
    Comment #99

    Thank you Michael for sharing your tips. I wanted to do this for some time. I am so glad your instructions were clear and precise, it worked on the first try.Cheers and more power to you and your blogging!

  100. Michael Martin
    March 9th at 8:05 pm GMT
    Comment #100

    Merci,
    I'm glad it worked for you, and that it was easy enough to follow! :)

  101. Adam Kayce
    March 12th at 10:13 pm GMT
    Comment #101

    Oh, perfect! Like a charm.It was the "don't show it if I don't have any" that I was looking for, and this worked like an absolute charm.Thanks so much.

  102. Michael Martin
    March 12th at 10:28 pm GMT
    Comment #102

    Adam,
    I like that as well. No need to mention trackbacks at all on a post that doesn't have any. :)

  103. Fabian
    March 16th at 10:36 am GMT
    Comment #103

    Thanks for this article, you explain it really clearly.:)I'll do this on my blog too, although it isn't really necessary yet, I don't get a lot of trackbacks and pingbacks.

  104. AJ
    March 19th at 6:33 pm GMT
    Comment #104

    I'm loving this little trick. Really clearly explained. I never really get trackbacks, but it still is pretty usefule :)

  105. Michael Martin
    March 19th at 11:40 pm GMT
    Comment #105

    Fabian and AJ,
    Ahh well. Just look forward to the times when you do get a lot of trackbacks, and a trick like this is needed. :D

  106. dinsan
    March 28th at 8:31 am GMT
    Comment #106

    Thanks .. it worked very well :)  

  107. djstelios
    March 28th at 11:31 am GMT
    Comment #107

    Very good hack. I've used it on my blog and now I like more the comments area. It's cleaner..Thanks

  108. alialtugkoca
    March 28th at 1:22 pm GMT
    Comment #108

    nice tip,thanks