Merge lp:~canonical-website-editors/blahblahblah/bug-1291268 into lp:blahblahblah

Proposed by Graham Bancroft
Status: Merged
Approved by: Graham Bancroft
Approved revision: 58
Merge reported by: Graham Bancroft
Merged at revision: not available
Proposed branch: lp:~canonical-website-editors/blahblahblah/bug-1291268
Merge into: lp:blahblahblah
Diff against target: 23 lines (+16/-0)
1 file modified
functions/general.php (+16/-0)
To merge this branch: bzr merge lp:~canonical-website-editors/blahblahblah/bug-1291268
Reviewer Review Type Date Requested Status
Anthony Dillon Approve
Review via email: mp+321843@code.launchpad.net

Description of the change

## Done

Add function so comment count only includes comments, not trackbacks

## QA

Go to https://design.canonical.com/2012/04/pebble-watch-and-ubuntu/ and note that there are 12 comments, this count includes the 2 trackbacks, now go to http://design-blog.canonicalwebteam.com/?p=33269 and note that the counts is 10, this doesn't include the 2 trackbacks

To post a comment you must log in.
Revision history for this message
Anthony Dillon (ya-bo-ng) wrote :

Thanks, some small suggestions in the code. Once addressed its +1

review: Approve
58. By Graham Bancroft

Fix bug 1291268 - Wrong number of comments reported

Revision history for this message
Graham Bancroft (gbancroft-canonical) wrote :

Code updated as per suggestions

Revision history for this message
Anthony Dillon (ya-bo-ng) wrote :

Thanks +1.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'functions/general.php'
2--- functions/general.php 2012-10-27 12:38:06 +0000
3+++ functions/general.php 2017-04-05 08:14:12 +0000
4@@ -117,3 +117,19 @@
5 remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
6 remove_action( 'wp_head', 'wp_generator' ); // Display the XHTML generator that is generated on the wp_head hook, WP version
7 // end remove unnecessary items from wp_head
8+
9+
10+add_filter('get_comments_number', 'comment_count', 0);
11+
12+function comment_count( $count ) {
13+ if ( ! is_admin() ) {
14+ global $id;
15+ $get_comments = get_comments('status=approve&post_id=' . $id);
16+
17+ $comments_by_type = separate_comments($get_comments);
18+
19+ return count($comments_by_type['comment']);
20+ } else {
21+ return $count;
22+ }
23+}

Subscribers

People subscribed via source and target branches

to all changes: