Revision: 36070
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 17, 2010 14:39 by wpCanyon
Initial Code
function commentCount($type = 'comments'){
if($type == 'comments'):
$typeSql = 'comment_type = ""';
$oneText = 'One comment';
$moreText = '% comments';
$noneText = 'No Comments';
elseif($type == 'pings'):
$typeSql = 'comment_type != ""';
$oneText = 'One pingback/trackback';
$moreText = '% pingbacks/trackbacks';
$noneText = 'No pinbacks/trackbacks';
elseif($type == 'trackbacks'):
$typeSql = 'comment_type = "trackback"';
$oneText = 'One trackback';
$moreText = '% trackbacks';
$noneText = 'No trackbacks';
elseif($type == 'pingbacks'):
$typeSql = 'comment_type = "pingback"';
$oneText = 'One pingback';
$moreText = '% pingbacks';
$noneText = 'No pingbacks';
endif;
global $wpdb;
$result = $wpdb->get_var('
SELECT
COUNT(comment_ID)
FROM
'.$wpdb->comments.'
WHERE
'.$typeSql.' AND
comment_approved="1" AND
comment_post_ID= '.get_the_ID()
);
if($result == 0):
echo str_replace('%', $result, $noneText);
elseif($result == 1):
echo str_replace('%', $result, $oneText);
elseif($result > 1):
echo str_replace('%', $result, $moreText);
endif;
}
Initial URL
http://wpcanyon.com/tipsandtricks/get-separate-count-for-comments-trackbacks-and-pingbacks-in-wordpress/
Initial Description
Initial Title
Get Separate Count For Comments Trackbacks And Pingbacks In WordPress
Initial Tags
wordpress
Initial Language
PHP