Improved separation of comments and pingbacks in Thematic 1.0.1

In previous versions of Thematic, the code to separate pingbacks and trackbacks has been based on this article by Ian Stewart. In that article he laments that comments and trackbacks are displayed in the same list by default and shows how to separate them in the comments template. The article was written in 2009, but the principle is common. Use a counter variable to count the number of comments and trackbacks and then make two separate loops to display them. The problem lies in that the paginate_comments_link() function only gets called on the comments list. There are no pagination links for the trackbacks.

Say you have 8 comments and 15 trackbacks, and you have set WordPress to display a maximum of 5 comments per page. That would give you 2 comment-pages and 3 trackback-pages, which is 13 responses = 5 pages altogether. But since we are separating the trackbacks from the pingbacks and the pagination links only were for the comments, the pagination would only show 2 pages and any trackback-pages beyond that would not be reachable. And on top of that, WordPress keeps track of the number of comment-pages internally so that when someone adds a comment they would be redirected to comment-page number 5 – which would be completely empty!

All of this has been addressed in the release of Thematic 1.0.1. For those of you who want to know how it’s done…

Separating comments and trackbacks

Let’s start with looking at some code. This snippet comes from the beginning of the comments loop.

// Collect the comments and pings
$thematic_comments = $wp_query->comments_by_type['comment'];
$thematic_pings = $wp_query->comments_by_type['pings'];

// Calculate the total number of each
$thematic_comment_count = count( $thematic_comments );
$thematic_ping_count = count( $thematic_pings );

// Get the page count for each
$thematic_comment_pages = get_comment_pages_count( $thematic_comments );
$thematic_ping_pages = get_comment_pages_count( $thematic_pings );

// Determine which is the greater pagination number between the two (comment,ping) paginations
$thematic_max_response_pages = ( $thematic_ping_pages > $thematic_comment_pages ) ? $thematic_ping_pages : $thematic_comment_pages;

// Reset the query var to use our calculation for the maximum page (newest/oldest)
if ( $overridden_cpage )
set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? $thematic_comment_pages : 1 );

First of all, there’s no need to have a counter in the comment loop to see how many comments and trackbacks you have. We can grab them directly from the query and count them. Pings are both trackbacks and pingbacks, they will be in the same list.

The get_comment_pages_count() function will calculate the number of pages for us, taking into account both the threading of the comments and the user seleted number of comments per page. We save the largest page number in a variable for later use.

The last bit is there to make sure the correct comment page is shown based on whether you have selected to show the newest or oldest comments first in your discussion settings. The $overridden_cpage variable is a global set by WordPress that decides which comment page to get by default.

Further down, we use our variable in the call to paginate_comments_link.


One more thing

Remember that WordPress keeps track of the number of comment-pages so that it sends new comments to the latest comment-page? We need to tell WordPress to re-calculate the comments-pages. Turns out we can filter get_comment_link.

function thematic_get_comment_link( $link , $comment, $args ) {
global  $wp_rewrite;

$args['type'] = 'comment';
$args['page'] = get_page_of_comment( $comment->comment_ID, $args );

if ( $wp_rewrite->using_permalinks() )
$link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' );
$link = add_query_arg( 'cpage', $args['page'] , get_permalink( $comment->comment_post_ID ) );

return $link;
add_filter( 'get_comment_link', 'thematic_get_comment_link', 10, 3 );

The important bit here is

$args['type'] = 'comment';

This makes sure that the comment-paging calculations will be done on comments only (and not trackbacks) and send the visitor to the correct place. This will also send them to the correct comment-page after replying to someone else’s comment.

So there you have it! There is still room for some fine-tuning of details, but our testing indicates that it works like it should. Hopefully not too many people were affected by the previous behaviour, but for those who were this update will be very welcome.


  1. There doesn’t seem to be a changelog available for Thematic 1.0.2 – could you post some details about that please?

    • middlesister
      | Permalink

      The changelog can be found in the readme. There is not too much change from 1.0.1. New filters for header and footer open and close tag, addition of a couple of language files, pot file in sync again, and the moving of thematic_doctitle to be added as a filter to wp_title. This was to comply with theme review guidelines for wp 3.4.

  2. Wonderful items from you, man. I have remember your stuff previous to and you are just too fantastic.

    I really like what you’ve bought here, certainly like what you are stating and the way
    through which you are saying it. You are making it
    entertaining and you continue to care for to keep
    it sensible. I can’t wait to read much more from you.
    That is actually a terrific site.

  3. Because the admin oof this website is working, no doubt very rapidly it will be renowned, due to its
    feature contents.

  4. Johng657
    | Permalink

    Very nice post. I certainly appreciate this website. cbdeffkdafbd

  5. By choosing products that have been tested and approved by a dermatologist to significantly
    reduce the likelihood of damage to the skin and, more importantly, greatly increases the likely hood that you are
    investing in a product that provides desirable results.
    If you already have lines and wrinkles it helps to remove them.
    And because certain vitamins and minerals react with others, and with medicines, it is important to discuss your choices with a doctor, nutritionist, or other healthcare professional to create a program tailored
    to your personal needs.

  6. Most men are not into gifts actually, but because you took effort in preparing
    unique presents for them, their prospective may likely to
    change. So this is why I will be bulk buying some velvet cushions and anything else I happen to notice that is
    nice and on offer, as. So if his or her birthday is just round the corner,
    and you are hunting for a special gift, here are a few unique birthday gifts ideas that are sure to delight the birthday boy or

  7. Because of the pitfalls associated with erroneous VAT Returns it is worth outsourcing the function to someone who is experienced,
    knowledgeable and up to date with current VAT rules
    and regulations, as well as how to treat specific items.
    Those are some of the key points that I would identify that you would want to find in accountants in Las Vegas.
    These individuals provide the best Tax Filing Support and will be able to
    help stop tax liens and in addition enable you to prevent tax levy difficulties like a Wage Levy or a Bank Levy from the IRS.

  8. Pests like cockroaches, spiders, rats, Wasps and
    bees, termites, etc can be spotted in any corner of the world.
    Infestations caused by creatures must not be ignored nor overlooked.
    If you already have a pest infestation, visit their site at to get a
    free estimate.

    Feel free to visit my page – pest control Philadelphia

  9. It is easy to install and it makes blogging quick and easy even for a beginner who is without any technical skills.

    So, why shouldn’t you be cashing in too inside online money making industry, well that is because you do not know
    the techniques to success yet. Why not create additional revenue streams so you won.

  10. Nowadays, all the manufacturers of these parts are well established even though some people were apprehensive about a few of them when they first started producing them.
    The relationship that they have with the manufacturer largely determines if they can do this.
    When you are exposed, on the basis of an error you’ve committed,
    then you’re “only human.

  11. I will rigyht away grasp your rss as I can’t in findin your e-mail
    subscription ink or newsletter service. Do you’ve any?
    Kindly let me know in order that I could subscribe.


    Feel free to surf to my site – Great Low Carb Diets

  12. Please let me know if you’re looking for a author for your blog.
    You have some really good posts and I feel
    I would be a good asset. If you ever want to take some of the load off,
    I’d love to write some articles for your blog in exchange for a link back to mine.
    Please send me an email if interested. Kudos!

  13. Hello, its fastidious paragraph on the topic of media print, we all understand media is
    a fantastic source of data.

  14. It’s going to be finish of mine day, but before ending I am reading this impressive paragraph to improve my experience.

  15. Very nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog
    posts. After all I’ll be subscribing to your feed and I hope you write again soon!

  16. An outstanding share! I’ve just forwarded this onto a co-worker who has been conducting a little homework on this.

    And he in fact ordered me dinner due to the fact that
    I stumbled upon it for him… lol. So let me
    reword this…. Thank YOU for the meal!! But yeah, thanx for spending time to discuss this subject here on your web

  17. Dehydration and exposure to heat can lead to a number of severe health
    risks in people and pets. As a house owner your job is to settle on a trustworthy company that can provide efficient
    service at an affordable price. Students who attend city
    colleges often do so to acquire an associate’s degree and many tend to pursue state colleges or universities to earn a bachelor’s degree.

  18. Do you have a spam problem on this website; I also am a blogger, and
    I was wondering your situation; we have created some nice procedures
    and we are looking to trade strategies with others, why not shoot me an e-mail
    if interested.

  19. Thanks for finally talking about > Improved separation of comments and pingbacks in Thematic 1.0.1 < Loved it!

  20. I blog frequently and I seriously appreciate your content.

    This great article has really peaked my interest.

    I’m going to bookmark your website and keep checking for new details about once a week.
    I opted in for your RSS feed as well.

  21. We stumbled over here different page and thought I might as well check things out.
    I like what I see so now i am following you. Look forward to
    finding out about your web page for a second time.

  22. I love what you guys tend to be up too. This sort of clever work and
    coverage! Keep up the fantastic works guys I’ve you guys to
    my blogroll.

  23. Greetings, I think your website might be having
    browser compatibility problems. Whenever I look at your web site in Safari, it
    looks fine but when opening in I.E., it’s got some overlapping issues.
    I just wanted to give you a quick heads up! Apart from that, wonderful blog!

  24. What’s up everyone, it’s my first pay a visit at this website, and paragraph is genuinely fruitful for me, keep up posting these articles.

  25. I have to thank you for the efforts you’ve put in penning this blog.
    I really hope to view the same high-grade blog posts
    from you later on as well. In fact, your creative writing abilities has inspired me to get my very own website now ;)

  26. Excellent beat ! I would like to apprentice while you amend your web site, how can i subscribe for a blog site?

    The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept

  27. Wonderful web site. Lots of useful information here.

    I am sending it to some friends ans also sharing in delicious.

    And naturally, thank you to your effort!

  28. Currently it looks like WordPress is the best blogging platform
    out there right now. (from what I’ve read) Is that what you are using on your blog?

  29. Hi there mates, how is everything, and what
    you desire to say concerning this paragraph, in my view its really
    awesome in support of me.

  30. Hi there! I know this is somewhat off-topic however I needed
    to ask. Does managing a well-established website like
    yours require a lot of work? I’m completely new to blogging
    but I do write in my journal everyday. I’d like to start a blog so I can share
    my experience and views online. Please let me know if you have any
    ideas or tips for new aspiring bloggers. Thankyou!

  31. I will right away take hold of your rss as I can’t to find your email subscription hyperlink or
    e-newsletter service. Do you’ve any? Please allow me realize in order that I may just subscribe.

  32. Hello it’s me, I am also visiting this web site regularly, this website is
    truly nice and the users are truly sharing fastidious thoughts.

  33. Excellent blog here! Also your web site loads up fast! What web host are
    you using? Can I get your affiliate link to your host?
    I wish my site loaded up as quickly as yours lol

  34. I was suggested this web site by way of my cousin. I’m no longer sure whether
    or not this submit is written by means of him as nobody else recognize such special about my
    problem. You are amazing! Thanks!

  35. Hello! I know this is somewhat off topic but I was wondering which blog platform are
    you using for this website? I’m getting sick and
    tired of WordPress because I’ve had issues with hackers and I’m looking at options for another platform.
    I would be fantastic if you could point me in the direction of a good platform.

  36. It’s very simple to find out any matter on web as compared to books, as I
    found this post at this site.

  37. Spot on with this write-up, I actually believe that
    this website needs a lot more attention. I’ll probably be back
    again to read through more, thanks for the information!

  38. This is really interesting, You are a very skilled
    blogger. I’ve joined your feed and look forward to seeking more of your
    magnificent post. Also, I’ve shared your website in my social networks!

  39. With havin so much content do you ever run into any issues
    of plagorism or copyright violation? My site
    has a lot of unique content I’ve either authored myself or outsourced but it looks like a lot of it is popping it
    up all over the internet without my agreement.
    Do you know any techniques to help stop content from being stolen? I’d definitely appreciate

  40. Thanks for the auspicious writeup. It actually was once a leisure account it.
    Glance advanced too far added agreeable from you!

    However, how could we keep up a correspondence?

    Look into my webppage :: Employee communications

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <cite> <code> <em> <strong> <pre class="" title=""> <p> <del> <ins> <ul> <ol> <li>