Make WordPress Core

Opened 11 years ago

Closed 9 years ago

Last modified 7 years ago

#24801 closed defect (bug) (worksforme)

comments_number() shows "0 Comments" after Theme Unit Test import

Reported by: exalted's profile eXalted Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.2
Component: Comments Keywords: close 2nd-opinion
Focuses: Cc:

Description

After importing the Theme Unit Test file in WP 3.5.2 and 3.6 RC, and viewing a post with comments attached to, comments_number() shows "0 Comments". However after writing a new comment, it updates and shows the correct number.

I've tested this in 3.5.2's Twenty Twelve and 3.6's Twenty Thirteen, the result is the same. In the Admin Comments page, the number in the bubble, under the post name that the comment is attached to, shows zero. Again this is before the "refresh with new comment" method.

http://oi40.tinypic.com/5md7qh.jpg

Change History (3)

#1 @rob1n
10 years ago

  • Keywords close 2nd-opinion added; needs-patch removed

Cannot reproduce on r26746. Fresh installation, imported the XML file downloaded from the Codex (https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml). Shows comment number fine in multiple places within the admin:

http://i.imgur.com/F6HDq5X.png

http://i.imgur.com/ciK7aHv.png

#2 @rachelbaker
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

I am unable to reproduce this issue either. I was also unable to find a ticket that would have fixed the reported issue.

#3 @samicooper
7 years ago

I experienced the same issue on page comments after importing the WP test data. This seems to do the trick:

<?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;
        }
}
Note: See TracTickets for help on using tickets.