Frumph / comic-easel

Comic Easel is a plugin for WordPress that let's you have a WebComic with any WordPress theme.
http://comiceasel.com
21 stars 13 forks source link

Link to comments in navigation does not show number for current page #8

Closed EmilyRyan closed 9 years ago

EmilyRyan commented 10 years ago

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.

Frumph commented 10 years ago

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

EmilyRyan commented 10 years ago

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!

Frumph commented 10 years ago

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

EmilyRyan commented 10 years ago

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)

Frumph commented 10 years ago

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?

Frumph commented 10 years ago

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

EmilyRyan commented 10 years ago

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

Frumph commented 10 years ago

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

EmilyRyan commented 10 years ago

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

Frumph commented 10 years ago

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

Frumph commented 10 years ago

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

EmilyRyan commented 10 years ago

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!

Frumph commented 9 years ago

Still an issue?

EmilyRyan commented 9 years ago

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).

Frumph commented 9 years ago

unless two of them are pingbacks and not displayed

EmilyRyan commented 9 years ago

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/

Frumph commented 9 years ago

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

Frumph commented 9 years ago

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'

EmilyRyan commented 9 years ago

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.

Frumph commented 9 years ago

$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

EmilyRyan commented 9 years ago

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;
    }
}

: )

Frumph commented 9 years ago

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

EmilyRyan commented 9 years ago

Forgot to say; I also removed the comment!

Frumph commented 9 years ago

\o/ yay hehe