You are here: WTF » Documentation » Extended Functionality Methods »

Pings Count

Pings Count

WTF provides you with a simple way to count the number of pings and trackbacks on your WordPress posts and pages. This is a small function which simply returns a count of all the pings and trackbacks for a post. To use the pings count add the following code somewhere in the loop:

<?php if(function_exists('wtf_pings_count')) $count = wtf_pings_count(get_the_ID()); ?>

You can then use the variable $count to do something with the post. For example if you only want to show a certain section of your page if there are any pings or trackbacks (like when separating pings/trackbacks and comments) you could do the following:

<?php 
if(function_exists('wtf_pings_count')){ 
    $count = wtf_pings_count(get_the_ID()); 
    if($count > 0){
        echo 'This post has pings/trackbacks.';
    }
}
?>

Note in the above example I am using the default WordPress function get_the_ID() to get the ID of the post.

Advanced

This method takes one argument:

wtf_pings_count($post_id);
  • $post_id
    • Description – The ID of the post/page you want to count the pings/trackbacks for.