• Resolved do77

    (@do77)


    Hi,

    I tried retrieving the comment count (I am using Facebook Comments for WordPress) for each post so I included
    <?php comments_number('no responses','one response','% responses'); ?>
    into my code. If I include it into the single.php it works fine and shows the correct number of comments posted. However, if I add the code snippet to the index.php (within the loop) it only says ‘Leave comment’ and does not show the number of comments already posted.

    Any idea why that is?

    Many thanks to all!
    do77

Viewing 10 replies - 1 through 10 (of 10 total)
  • does your index.php show your comments template, or just a link and you want it to display comment numbers?

    If the second, use comments_popup_link

    https://codex.www.ads-software.com/Function_Reference/comments_popup_link

    Thread Starter do77

    (@do77)

    The index.php does not show the comments template. I basically have a link below each post either saying ‘Leave comment’ or displaying the number of comments (well, that’s at least my goal).

    I just tried it with the comments_popup_link but it still does not work. It only says ‘Leave comment’ but does not show the count ??

    Thread Starter do77

    (@do77)

    Could the reason be my comments.php file? Because the WP comments would show up below the ‘facebook comments’ after installing the plugin I deleted most of what is in the comments.php file.

    This is what is left:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    // Do not delete these lines
    	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
    		die ('Please do not load this page directly. Thanks!');
    
    	if ( post_password_required() ) { ?>
    		<p class="nocomments"><?php _e("This post is password protected. Enter the password to view comments.", ''); ?></p>
    	<?php
    		return;
    	}
    ?>

    Anything wrong with that?

    Similar post here: https://www.ads-software.com/support/topic/plugin-facebook-comments-for-wordpress-comment-count-not-calculating?replies=2

    No response yet. Still waiting for the fix. New version still has some bugs.

    Apologies, I didn’t realize the plugin affected things differently, I can’t answer the question as I don’t use that plugin at all….

    After debugging and tracing the plugin codes, I fixed it. I just need to remove a line of condition ($fbc_options['displayPagesOrPosts'] == 'posts') && (!is_single()) around line 27 in facebook-comments-combinecomments.php file (that’s for 3.0.2 version).

    For version 2.1.2 or lower, you can find it in facebook-comments-functions.php around line 173.

    Hope this helps.

    Thread Starter do77

    (@do77)

    Perfect! That worked for me as well. Thanks so much eugenealegiojo!

    I am using 3.1.3 and not getting any accurate count (always zero) on either the index.php or the single.php.

    If it’s any clue, I have a one other bug: the option to “Check the Post comment to my Facebook profile box by default” seems to have no effect (the option is always checked).

    Any idea if I’m doing something wrong or if this is just buggy?

    thanks,
    joel

    i have issue too i dont see comments count just No comments yet.

    heres is code of facebook-comments-combinecomments.php

    } elseif (!comments_open() ||
    			  ($fbc_options['displayPagesOrPosts'] == 'pages') && (!is_page()) ||
     ($fbc_options['displayPagesOrPosts'] == 'posts') && (!is_single())) {
    			 	  return $wpCommentCount;
    	} else {

    but if i erase the line ($fbc_options['displayPagesOrPosts'] == 'posts') && (!is_single())) i get blank page.

    thanks in advance.

    eugenealegiojo‘s fix no longer seems to work for 3.1.3, so post counts on the index page are all screwed up and displaying the same # for each post, regardless of how many comments that post has.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Comment count – only works on single.php but not on index.php’ is closed to new replies.