[resolved] Comment counter shows the same number on all posts (7 posts)

  1. mrwangkai
    Posted 6 years ago #

    I'm currently employing a latest customized theme of Cognoblue and is running into some walls trying to figure out how my comment counter shows the exact same number on all the posts.

    My site is here: careace

    I narrowed it down to problem with theme because the issue does not exist if I switch it to a different theme.

    Am using this to show comment:
    <?php comments_popup_link(__('<strong>Comments (0)</strong>'), __('<strong>Comments (1)</strong>'), __('<strong>Comments (%)</strong>')); ?>

    The problem is, there is not problem with the code. Can anyone suggest where I should check next for problem?

    (Basically, from the code above, if I substitute any number with the % in Comments(%), the output would be: Comment (whatever # you have placed))


  2. MichaelH
    Posted 6 years ago #

    What happens if you use this code from the WordPress Default theme:

    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>

    See Template_Tags/comments_popup_link

  3. mrwangkai
    Posted 6 years ago #

    Thanks MichaelH,

    Same thing, it kept saying Comment (2).
    If I were to change the % in the above code to the number 9, the comment will say (9).

    Using the same code elsewhere, such as on an archive page with all the posts, the number of comment will display correctly (zero meant 0 and two meant 2).

    I figured it must be a problem with the theme for that particular section. It's a customized theme where the original version does not consist this problem.

    Any other pointer from anyone? Greatly appreciate it!

  4. mrwangkai
    Posted 6 years ago #

    Okay, i think i may know why.

    I have 2 php files included. one of them is doing query_posts and the other is trying to get_post. Now, when I make one of them invalid, the comment becomes normal.

    So my new question is how can you get posts (by using either function) to show articles in 2 different places on the same page?

    I used this for the first php file:

    global $post;
    $myposts = get_posts('numberposts=5&category=9');
    foreach($myposts as $post) :

    and this for the second php file:

    <?php query_posts('showposts=4&cat=24'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php endwhile; ?>
    <?php endif; ?>


  5. mrwangkai
    Posted 6 years ago #


  6. MichaelH
    Posted 6 years ago #

  7. mrwangkai
    Posted 6 years ago #

    I used method provided here and it was resolved.


    Good resource too, MichaelH. :)

    case closed!

Topic Closed

This topic has been closed to new replies.

About this Topic