Ping/Track/Comment Count

About

This plugin, co-created by Chris J. Davis, Scott Merrill, and Mark Jaquith in one magical rainbow-filled night contains two functions that return and echo the number of pingbacks, trackbacks, combined pings or regular comments for a WordPress entry.

This is of particular use to people who want to separate their regular comments from their pings. The plugin is “smart” and will grab all the numbers in one go the first time you call it, so that subsequent calls use no database queries, making it very efficient.

Download

Usage

There are two functions you can use: get_comment_type_count() (which returns the value) and comment_type_count() (which echoes the value).

Both functions operate identically, and take 2 optional parameters. The first parameter is the type of comment you would like returned (defaults to ‘all’). Your options are trackback, pingback, ping, and comment.

For example, pretend that a post has 1 pingback, 2 trackbacks, and 4 regular comments.

<?php
comment_type_count('pingback'); // prints "1"
comment_type_count('trackback'); // prints "2"
comment_type_count('ping'); // prints "3" (1 pingback + 2 trackbacks)
comment_type_count('comment'); // prints "4"
comment_type_count(); // prints "7" (1 pingback + 2 trackbacks + 4 comments)
?>

The second parameter, which is also optional, is a post ID. By default, the function just gives you the number for the current post being processed in “the loop.” By passing a specific post ID, you can get the count for any post ID you wish.

<?php
comment_type_count('pingback', 534); // prints number of pingbacks on entry 534
?>

Donate

I’ve spent a lot of time writing this code and supporting it. If you derive some benefit from this code, please consider showing your gratitute in a more tangible
way. Thanks!

I have received $0 this month for my coding efforts.

Donate with PayPalAmazon.com Wishlist


65 Responses to “Ping/Track/Comment Count”

  1. Micha says:

    Source Code couldn’t be displayed. :(

  2. Mark says:

    Micha, just moved to a new server. Thanks for pointing that out. I’ll try and get that fixed.

  3. Mark says:

    Alright, it should be fixed now!

  4. [...] skippy Member Chris Davis’ separation anxiety is a good one. Also look at Mark Jaquith’s ping/track count. Posted: 2005-08-27 01:51:07 # [...]

  5. bangbang023 says:

    When I added the code to my post.php file, it limited my index to one post per page. Is there a way to solve this? This seems to be the only working plugin to so all of this, right now.

  6. Mark says:

    Did you get an error? The only reason I can think that it would limit it to one post is if there was an error and it stopped outputting the page after that. Let me know what the error was and I’ll look into it.

  7. bangbang023 says:

    No, unfortunately, there was no error outputted

  8. Mark says:

    You sure? You viewed the source of the page and looked at the place where the function is called and there was no error?

  9. bangbang023 says:

    No error at all. There’s not even a whitespace in the source where the function is being called.

  10. John Cass says:

    Hi, does this mean that I can count the number of trackbacks, and comments on another blog?

    John

  11. John Cass says:

    Hi, sorry I understand your plugin is for the an individual blog, my real question is this, how would I count comments or trackbacks on another blog without having to do it manually?

  12. Mark says:

    You can’t. You’d need access to their database.

  13. Madthiu says:

    Hi, I am having problem with this great plugin. When I activate it in my WP2.0 plugin page, the following message shown above my admin page header after the plugin page is reloaded:

    Warning: Cannot modify header information – headers already sent by (output started at /home/.fenestra/madthiu/blog/wp-content/plugins/ping-track-comment-count.php:81) in /home/.fenestra/madthiu/blog/wp-admin/plugins.php on line 16

    And it makes one of my plugin, the LiveCalendar not working. Everything back to normal when “Ping/Track/Comment Count” is disabled. May I know if there is anything I can modify in my blog to solve the conflict? (Except disabling LiveCalendar)

    Thank you.

  14. Mark says:

    You must have an extra space after the closing ?> in the plugin … make sure there is no space after that.

  15. Madthiu says:

    Yeah~! It’s fixed, thanks~!! :D

  16. John Cass says:

    Thanks Mark, makes sense.

  17. [...] No jako¶ nie mogê nic znale¼æ :/EDIT:jest wtyczka: http://txfx.net/code/wordpress/ping-track-comment-count/ Ten post by³ edytowany przez Fanatyk: Dzisiaj, 14:47 ——————– # Znikaj±ce posty i inne k³opoty "z forum" # [forum Gaduly.com] # Tani Profesjonalny Hosting [...]

  18. Mark says:

    just wondering where to put this code. as i can’t find the post.php file

  19. Mark says:

    Within the WordPress loop would be the best location.

  20. [...] Probably because there’s an old age rule in the world of WordPress, from what I have seen… “If you thought it up, chances are there’s a plugin for it.” There’s a plugin on tempus fugit that does what you are requesting. When in doubt, search the WordPress codex plugin list as well as wp-plugins.net. If you can’t find what you are looking for, even after a google search, then it’s safe to assume that there’s no plugin for what you want. In that case, posting in a forum would be your best bet, seeing if other people like that idea, then the coders come in, and you probably know the rest. ^_~ [...]

  21. Tom Edwards says:

    Thanks, that’s exactly what I was looking for! In fact there’s quite a lot of stuff you’ve got here that I’d like to ‘borrow’; could you please point me towards the plugin/tag/whatever for the Blog Author/Subscribed buttons you’re using? Thanks again. :-)

  22. Jan says:

    Seems that it doesn’t work with Wordpress 2.0.3. I get an error about already send headers everytime I try to save a document and the default WYSIWYG Editor is gone.

  23. Jan says:

    I always get the following error message after activating this plugin:
    Warning: Cannot modify header information – headers already sent by (output started at wp-content/plugins/count_trackbacks.php:64) in wp-includes/pluggable-functions.php on line 272

    Does somebody know it? Or better does somebody know how to fix it?

  24. Will says:

    Hi,

    [quote]When I added the code to my post.php file, it limited my index to one post per page. Is there a way to solve this? This seems to be the only working plugin to so all of this, right now.[/quote]

    I am getting the same thing! :( No errors of any kind either.

    Also, for your example how can I make it output:

    1 pingback
    2 trackbacks
    3 pings
    4 comments

    Take Care,

    Will

  25. Brytney says:

    Your site is perfect!

  26. Seb says:

    Nice! I’ll definately check back here!

  27. I can do a blog on your website? how much it will cost?

  28. [...] una etiqueta <!–more–> para cortar el texto. Los otros plugins instalados son Ping/Track/Comment Count con tal de separar los comentarios de los trackbacks, Related Posts para mostrar entradas [...]

  29. Visitor765 says:

    I have visited your site 116-times

  30. Visitor892 says:

    I could not find this site in the Search Engines index

  31. DDT-WEBKINZ says:

    I thought that the WTO would be a good start for transforming the process of government at least across national borders. I quite like the idea of using the secretariat of the WTO as the centre for a Wikipedia of trade – a sort of open source world government at least for a very specific and complicated issue which needs many brains to provide a solution.

  32. Stasigrii says:

    Hello, very nice site, keep up good job!
    Admin good, very good.

  33. poer says:

    hi, thanks for the code, very handy to help me separate my pings and comments.

  34. list of the posts with the most comments. Modified for Last X days … by DJ Chuang. Author: Nick Momrik Nicer trackbacks Changes the display of trackbacks from [...] Tracbackback text [...] to something a little more readable. Author: Rachel CunliffePing/Track/Comment CountFunctions that return or display the number of trackbacks, pingbacks, comments or combined pings recieved by a given post. Author: Mark Jaquith Maintenance Mode Plugin Adds a splash page to your blog that lets visitors know your blog is down for

  35. list of the posts with the most comments. Modified for Last X days … by DJ Chuang. Author: Nick Momrik Nicer trackbacks Changes the display of trackbacks from [...] Tracbackback text [...] to something a little more readable. Author: Rachel CunliffePing/Track/Comment CountFunctions that return or display the number of trackbacks, pingbacks, comments or combined pings recieved by a given post. Author: Mark Jaquith Maintenance Mode Plugin Adds a splash page to your blog that lets visitors know your blog is down for

  36. [...] Kita juga bisa untuk membuat judul bagian Pingback/Trackback tidak muncul jika tidak ada satupun Pingback/Trackback yang masuk untuk artikel tersebut, tapi untuk melakukan hal ini, kita harus menginstall plugin tambahan yang bernama Ping/Track/Comment Count. [...]

  37. [...] is an impressive light weight plugin: Ping/Track/Comment Count by Mark Jaquith which calculates the total number of comments, pingbacks and trackbacks through the [...]

  38. [...] Untuk melakukan hal itu, kita harus menginstall plugin tambahan yang bernama Ping/Track/Comment Count. [...]

  39. [...] Ping/Track/Comment Count – So I can separate comments from trackbacks from pings [...]

  40. [...] Ping/Track/Comment Count – Counts the comments seperately from the pings. Recommended for correct function of this theme [...]

  41. Michael says:

    I think there’s one option that’s missing in this plugin, and that is the ability to show only actual comments with the pings filtered out. It would be nice if that option could be added.

    Like this:
    pingback – show only pingbacks
    trackback – show only trackbacks
    ping – show pingbacks + trackbacks
    onlycomment – show only comments
    comment – show comments + pingbacks + trackbacks

  42. Gume says:

    I was searching for very similar plug-in. I will check it if it fits me, thnx.

  43. [...] Ping Track Comment Count Tempus Fugit by Mark Jaquith Posted by root 1 hour 59 minutes ago (http://txfx.net) Los otros plugins instalados son ping track comment count con tal de separar los author rachel cunliffeping track comment countfunctions that return or display the mike davidson mike industries now powered by wordpress says Discuss  |  Bury |  News | Ping Track Comment Count Tempus Fugit by Mark Jaquith [...]

  44. [...] Ping Track Comment Count Tempus Fugit by Mark Jaquith Posted by root 17 minutes ago (http://txfx.net) Take care will motorcycle online says mar 14th 2007 at 2 07 pm los otros plugins instalados son ping track comment count con tal de separar los comentarios de mike davidson mike industries now powered by wordpress says Discuss  |  Bury |  News | Ping Track Comment Count Tempus Fugit by Mark Jaquith [...]

  45. [...] Ping Track Comment Count Tempus Fugit by Mark Jaquith Posted by root 18 minutes ago (http://txfx.net) Take care will motorcycle online says mar 14th 2007 at 2 07 pm los otros plugins instalados son ping track comment count con tal de separar los comentarios de mike davidson mike industries now powered by wordpress says Discuss  |  Bury |  News | Ping Track Comment Count Tempus Fugit by Mark Jaquith [...]

  46. [...] Ping Track Comment Count Tempus Fugit by Mark Jaquith Posted by root 1 hour 1 minute ago (http://txfx.net) In fact there quite a lot of stuff you 39 ve got here that i 39 d like to 39 borrow 39 wordpress plugins database plugin details ping track comment count says a very specific and complicated issue which needs many brains to provide a solution mike davidso Discuss  |  Bury |  News | Ping Track Comment Count Tempus Fugit by Mark Jaquith [...]

  47. [...] Ping Track Comment Count Tempus Fugit by Mark Jaquith Posted by root 4 minutes ago (http://txfx.net) Mike davidson mike industries now powered by wordpress says ping track comment count tempus fugit by mark jaquith wood tv stand says Discuss  |  Bury |  News | Ping Track Comment Count Tempus Fugit by Mark Jaquith [...]

  48. Ezuca says:

    Oh my! Thanks a lot. I thought I would have a hard time in finding a solution to my problem. Thanks again. You really helped.

  49. ostrov says:

    Thank you,
    very interesting article

  50. burçlar says:

    Thank you,
    very interesting article

Leave a Reply

Note: If you are replying to another commenter, click the "Reply to {NAME} →" button under their comment to help the conversation have a better flow!

Anti-Spam Quiz: