I think you can use get_comments
.
In the type
parameter you can pass the type of comment (trackback, ping), you can filter by status, and you have a parameter called count
, that when is set to true
returns just the number of comments that match the parameters you passed.
get_comments(
array(
'status' => 'approve',
'post_id'=> get_the_ID(),
'type'=> 'pings',
'count' => true)
);
This example gets the number of approved pings for a post, you have to use it inside a loop, if not, the function get_the_ID()
wont work, but you just have to pass the ID as you want.