[wp-trac] [WordPress Trac] #24801: comments_number() shows "0 Comments" after Theme Unit Test import
WordPress Trac
noreply at wordpress.org
Fri Sep 2 12:22:51 UTC 2016
#24801: comments_number() shows "0 Comments" after Theme Unit Test import
-------------------------------+-------------------------
Reporter: eXalted | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Comments | Version: 3.5.2
Severity: normal | Resolution: worksforme
Keywords: close 2nd-opinion | Focuses:
-------------------------------+-------------------------
Comment (by samicooper):
I experienced the same issue on page comments after importing the WP test
data. This seems to do the trick:
{{{#!php
<?php
add_filter('get_comments_number', 'comment_count', 0);
function comment_count( $count ) {
if ( ! is_admin() ) {
global $id;
$comments_by_type =
&separate_comments(get_comments('status=approve&post_id=' . $id));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/24801#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list