Sorry.. noob question... but I'm pulling my hair out over here...
I'm trying to return the number of comments for a specific post. Basically just adding a comment count to the Global Posts Widget (curious why it's not available, but anyway...).
Could you help me diagnose why this returns "--", even though when I use this SQL in phpMyAdmin, it returns the correct value (2)?
function comment_count($blog_id, $post_id)
{
global $wpdb;
$result = $wpdb->get_results(
"
SELECT Count ( * ) AS comment_count
FROM bowwp_site_comments
WHERE blog_id=105
AND comment_post_id=66
"
);
$comments = $result['comment_count'];
if ( ! $comments) {
return "--";
} else {
return $comment_count;
}
}