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.

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.