[GH-ISSUE #8] Link to comments in navigation does not show number for current page #9

Closed
opened 2026-06-06 22:28:58 -04:00 by yindo · 24 comments
Owner

Originally created by @EmilyRyan on GitHub (Jul 27, 2014).
Original GitHub issue: https://github.com/Frumph/comic-easel/issues/8

In the Comic Easel config there is an option that I left activated:

Enable the comment link in the comic navigation?
When this is enabled, a link will appear in the navigation that lets you go to the comments section of the current post, it also shows how many comments there currently are.

Problem is, on each comic page of my site except the main page, the parenthesized number shows the total amount of comments I have received (2) on a different page, this one: http://emilyryan.se/gramarye/comic/the-roster-of-names/

Whether this is a bug or me setting up the URL:s wrong I can't say, but I thought I'd report it just in case.

Originally created by @EmilyRyan on GitHub (Jul 27, 2014). Original GitHub issue: https://github.com/Frumph/comic-easel/issues/8 In the Comic Easel config there is an option that I left activated: <strong>Enable the comment link in the comic navigation?</strong> When this is enabled, a link will appear in the navigation that lets you go to the comments section of the current post, it also shows how many comments there currently are. Problem is, on each comic page of my site except the main page, the parenthesized number shows the total amount of comments I have received (2) on a different page, this one: http://emilyryan.se/gramarye/comic/the-roster-of-names/ Whether this is a bug or me setting up the URL:s wrong I can't say, but I thought I'd report it just in case.
yindo closed this issue 2026-06-06 22:28:58 -04:00
Author
Owner

@Frumph commented on GitHub (Oct 22, 2014):

It appears to be working properly, what it does it go to the section of the single comic page for it and then moves the browser to the comments area

<!-- gh-comment-id:60058872 --> @Frumph commented on GitHub (Oct 22, 2014): It appears to be working properly, what it does it go to the section of the single comic page for it and then moves the browser to the comments area
Author
Owner

@EmilyRyan commented on GitHub (Oct 22, 2014):

Just to clarify: for me, the number in the parenthesis does not show the number of comments for the current page, but a different one, so it becomes misleading. I thought it was a problem with my php-files but the same problem is exhibited here: http://comiceasel.com/comic/segway/#comments

This is a detail of course. Thank you for your hard work!

<!-- gh-comment-id:60141942 --> @EmilyRyan commented on GitHub (Oct 22, 2014): Just to clarify: for me, the number in the parenthesis does not show the number of comments for the current page, but a different one, so it becomes misleading. I thought it was a problem with my php-files but the same problem is exhibited here: http://comiceasel.com/comic/segway/#comments This is a detail of course. Thank you for your hard work!
Author
Owner

@Frumph commented on GitHub (Oct 22, 2014):

The link you provided shows 0 comments and has 0 comments ... on the comiceasel.com site

<!-- gh-comment-id:60147286 --> @Frumph commented on GitHub (Oct 22, 2014): The link you provided shows 0 comments and has 0 comments ... on the comiceasel.com site
Author
Owner

@EmilyRyan commented on GitHub (Oct 23, 2014):

Yes, the Segway link has 0 comments, so it's not completely the same, I only provide it as an example of other things that seem odd: when I click the comment button my browser (Chrome or Firefox) window doesn't jump to a comments anchor.
If you look at this link instead, a page of mine without comments, it lists comment number as 2: http://emilyryan.se/gramarye/comic/im-strong-willed-just-not-right-now/
(The link I provided in the very first post was the only page with comments, i.e the only single page that works)

<!-- gh-comment-id:60199785 --> @EmilyRyan commented on GitHub (Oct 23, 2014): Yes, the Segway link has 0 comments, so it's not completely the same, I only provide it as an example of other things that seem odd: when I click the comment button my browser (Chrome or Firefox) window doesn't jump to a comments anchor. If you look at this link instead, a page of mine without comments, it lists comment number as 2: http://emilyryan.se/gramarye/comic/im-strong-willed-just-not-right-now/ (The link I provided in the very first post was the only page with comments, i.e the only single page that works)
Author
Owner

@Frumph commented on GitHub (Oct 23, 2014):

I see it now. - on your site.

.. that can happen if there was something taking over the filter, or the $post->ID gets corrupted but it's not .. it also can happen if you have trackbacks but are not showing those trackbacks.

Can I get a screen capture of your (wp-admin)dashboard -> comments - section?

<!-- gh-comment-id:60218398 --> @Frumph commented on GitHub (Oct 23, 2014): I see it now. - on your site. .. that can happen if there was something taking over the filter, or the $post->ID gets corrupted but it's not .. it also can happen if you have trackbacks but are not showing those trackbacks. Can I get a screen capture of your (wp-admin)dashboard -> comments - section?
Author
Owner

@Frumph commented on GitHub (Oct 23, 2014):

As for the links not working, it's because the old version of Responsive you're using doesn't have the #comments ID showing unless there are actually comments there

http://emilyryan.se/gramarye/comic/the-roster-of-names/#comments This one works because there's actually comments. It's a bug in the theme that's causing the other's not working

<!-- gh-comment-id:60221706 --> @Frumph commented on GitHub (Oct 23, 2014): As for the links not working, it's because the old version of Responsive you're using doesn't have the #comments ID showing unless there are actually comments there http://emilyryan.se/gramarye/comic/the-roster-of-names/#comments This one works because there's actually comments. It's a bug in the theme that's causing the other's not working
Author
Owner

@EmilyRyan commented on GitHub (Oct 23, 2014):

Is this the one you mean?
skarmavbild 2014-10-23 kl 12 58 37

<!-- gh-comment-id:60222681 --> @EmilyRyan commented on GitHub (Oct 23, 2014): Is this the one you mean? ![skarmavbild 2014-10-23 kl 12 58 37](https://cloud.githubusercontent.com/assets/8282630/4751868/a6307d22-5aa3-11e4-9884-a8f7e9b42ca5.png)
Author
Owner

@Frumph commented on GitHub (Oct 23, 2014):

Yes, absolutely - Now we've narrowed it down to it not being trackbacks not-showing

So the next step is to check if you have any plugins that might be filtering the comments section - to do that, you basically disable and clear cache of all plugins except the comic easel plugin then you check the posts to see if it's still saying the (2) on it

<!-- gh-comment-id:60222979 --> @Frumph commented on GitHub (Oct 23, 2014): Yes, absolutely - Now we've narrowed it down to it not being trackbacks not-showing So the next step is to check if you have any plugins that might be filtering the comments section - to do that, you basically disable and clear cache of all plugins except the comic easel plugin then you check the posts to see if it's still saying the (2) on it
Author
Owner

@EmilyRyan commented on GitHub (Oct 23, 2014):

I use Akismet and Slim Jetpack. Akismet and Jetpack deactivated and cache emptied show no change for me yet.

<!-- gh-comment-id:60223470 --> @EmilyRyan commented on GitHub (Oct 23, 2014): I use Akismet and Slim Jetpack. Akismet and Jetpack deactivated and cache emptied show no change for me yet.
Author
Owner

@Frumph commented on GitHub (Oct 23, 2014):

Okay go ahead and put them back on clearing cache again - and thank you for helping me debug.

<!-- gh-comment-id:60223715 --> @Frumph commented on GitHub (Oct 23, 2014): Okay go ahead and put them back on clearing cache again - and thank you for helping me debug.
Author
Owner

@Frumph commented on GitHub (Oct 23, 2014):

I made some changes to this github in the way of the comments appearing, if it still continue's then the only thing i can think of is that the theme is filtering the comments code changing the $post->ID to something other then it should be

<!-- gh-comment-id:60225320 --> @Frumph commented on GitHub (Oct 23, 2014): I made some changes to this github in the way of the comments appearing, if it still continue's then the only thing i can think of is that the theme is filtering the comments code changing the $post->ID to something other then it should be
Author
Owner

@EmilyRyan commented on GitHub (Oct 23, 2014):

I have updated the injections.php, navigation.php and comiceasel.php on my server (the files I saw you had changed within the last hour). I don't see any change yet so I guess it's a problem with the theme.
Thank you for your help!

<!-- gh-comment-id:60230981 --> @EmilyRyan commented on GitHub (Oct 23, 2014): I have updated the injections.php, navigation.php and comiceasel.php on my server (the files I saw you had changed within the last hour). I don't see any change yet so I guess it's a problem with the theme. Thank you for your help!
Author
Owner

@Frumph commented on GitHub (Sep 28, 2015):

Still an issue?

<!-- gh-comment-id:143641177 --> @Frumph commented on GitHub (Sep 28, 2015): Still an issue?
Author
Owner

@EmilyRyan commented on GitHub (Sep 28, 2015):

Yeah... no change. I don't know what to do.
http://emilyryan.se/gramarye/comic/the-roster-of-names/#comments isn't perfect either, the comments in the next, previous navigation should show (2).

<!-- gh-comment-id:143717381 --> @EmilyRyan commented on GitHub (Sep 28, 2015): Yeah... no change. I don't know what to do. http://emilyryan.se/gramarye/comic/the-roster-of-names/#comments isn't perfect either, the comments in the next, previous navigation should show (2).
Author
Owner

@Frumph commented on GitHub (Sep 28, 2015):

unless two of them are pingbacks and not displayed

<!-- gh-comment-id:143732722 --> @Frumph commented on GitHub (Sep 28, 2015): unless two of them are pingbacks and not displayed
Author
Owner

@EmilyRyan commented on GitHub (Sep 28, 2015):

No, I'm almost certain they aren't, or rather, it would be an incredible coincidence. Comments (4) is displayed on every page except the starting page. It is the total number of comments that I have on comic pages in total.
Page with zero comments showing (4): http://emilyryan.se/gramarye/comic/trail-of-seals/
Page with two comments showing (4): http://emilyryan.se/gramarye/comic/the-sheep-rises/

<!-- gh-comment-id:143735588 --> @EmilyRyan commented on GitHub (Sep 28, 2015): No, I'm almost certain they aren't, or rather, it would be an incredible coincidence. Comments (4) is displayed on every page except the starting page. It is the total number of comments that I have on comic pages in total. Page with zero comments showing (4): http://emilyryan.se/gramarye/comic/trail-of-seals/ Page with two comments showing (4): http://emilyryan.se/gramarye/comic/the-sheep-rises/
Author
Owner

@Frumph commented on GitHub (Sep 28, 2015):

Your theme has a filter on it.

/core/includes/functions-extras.php

line: 67
add_filter( 'get_comments_number', 'responsive_comment_count', 0 );

if you encapsulate that line with /* */ (or) two // slashes in front of it to comment it out from running, tell me if it still happens

The function it runs is written wrong:

function responsive_comment_count( $count ) {
    if ( !is_admin() ) {
        global $id;
        $comments         = get_comments( 'status=approve&post_id=' . $id );
        $comments_by_type = separate_comments( $comments );

        return count( $comments_by_type['comment'] );
    } else {
        return $count;
    }
}

That should be global $post; and &post_id=' . $post->ID

Cause $id can't be guaranteed to have the right value inside of it with everything going on in a page, should not be used in this method

<!-- gh-comment-id:143881227 --> @Frumph commented on GitHub (Sep 28, 2015): Your theme has a filter on it. /core/includes/functions-extras.php line: 67 add_filter( 'get_comments_number', 'responsive_comment_count', 0 ); if you encapsulate that line with /\* */ (or) two // slashes in front of it to comment it out from running, tell me if it still happens The function it runs is written wrong: ``` function responsive_comment_count( $count ) { if ( !is_admin() ) { global $id; $comments = get_comments( 'status=approve&post_id=' . $id ); $comments_by_type = separate_comments( $comments ); return count( $comments_by_type['comment'] ); } else { return $count; } } ``` That should be global $post; and &post_id=' . $post->ID Cause $id can't be guaranteed to have the right value inside of it with everything going on in a page, should not be used in this method
Author
Owner

@Frumph commented on GitHub (Sep 28, 2015):

also (in addition to)

if (!is_admin() && in_the_loop()) {

would make it so it only runs on sections that are 'in the main loop'

<!-- gh-comment-id:143885271 --> @Frumph commented on GitHub (Sep 28, 2015): also (in addition to) ``` if (!is_admin() && in_the_loop()) { ``` would make it so it only runs on sections that are 'in the main loop'
Author
Owner

@EmilyRyan commented on GitHub (Sep 29, 2015):

I commented out line 67 and added && in_the_loop(). It works like a charm!
Thank you for the help, I would never have found it myself! Looking through other people's themes is beyond what anyone would hope for, so thank you.

<!-- gh-comment-id:143967409 --> @EmilyRyan commented on GitHub (Sep 29, 2015): I commented out line 67 and added && in_the_loop(). It works like a charm! Thank you for the help, I would never have found it myself! Looking through other people's themes is beyond what anyone would hope for, so thank you.
Author
Owner

@Frumph commented on GitHub (Sep 29, 2015):

$post and $post->ID replacing $id one and in_the_loop() is the fix ..

the commenting out the line only tests if that was where the problem was ;)

sorry I didn't make myself clearer heh

<!-- gh-comment-id:144005184 --> @Frumph commented on GitHub (Sep 29, 2015): $post and $post->ID replacing $id one and in_the_loop() is the fix .. the commenting out the line only tests if that was where the problem was ;) sorry I didn't make myself clearer heh
Author
Owner

@EmilyRyan commented on GitHub (Sep 29, 2015):

This is what I did, everything seems to work:

function responsive_comment_count( $count ) {
    if ( !is_admin() && in_the_loop()) {
        global $post;
        $comments         = get_comments( 'status=approve&post_id=' . $post->ID );
        $comments_by_type = separate_comments( $comments );

        return count( $comments_by_type['comment'] );
    } else {
        return $count;
    }
}

: )

<!-- gh-comment-id:144009501 --> @EmilyRyan commented on GitHub (Sep 29, 2015): This is what I did, everything seems to work: ``` function responsive_comment_count( $count ) { if ( !is_admin() && in_the_loop()) { global $post; $comments = get_comments( 'status=approve&post_id=' . $post->ID ); $comments_by_type = separate_comments( $comments ); return count( $comments_by_type['comment'] ); } else { return $count; } } ``` : )
Author
Owner

@Frumph commented on GitHub (Sep 29, 2015):

yeah but if you comment out line 67 it won't even run that ;/ so try it without 67 commented out if it breaks it again, recomment

<!-- gh-comment-id:144027625 --> @Frumph commented on GitHub (Sep 29, 2015): yeah but if you comment out line 67 it won't even run that ;/ so try it without 67 commented out if it breaks it again, recomment
Author
Owner

@EmilyRyan commented on GitHub (Sep 29, 2015):

Forgot to say; I also removed the comment!

<!-- gh-comment-id:144029756 --> @EmilyRyan commented on GitHub (Sep 29, 2015): Forgot to say; I also removed the comment!
Author
Owner

@Frumph commented on GitHub (Sep 29, 2015):

\o/ yay hehe

<!-- gh-comment-id:144030614 --> @Frumph commented on GitHub (Sep 29, 2015): \o/ yay hehe
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Frumph/comic-easel#9