[resolved] comments_template not working on single.php (6 posts)

  1. techpavan
    Posted 7 years ago #


    I am a blogger at http://www.techpavan.com.

    I am working on a new theme for my blog and came with a small problem and need a solution about that.

    I use domtab on single.php and am displaying popular, related and featured posts in the domtab. Related and Popular posts are been displayed using plugins yarpp and popularity contest. No problem with those.

    Coming to the problem.
    To display featured posts, I am using wp query code as below.

    <?php $my_query = new WP_Query('cat=46 &showposts= 10');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID; ?>
    <p><ol><li><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></li></ol></p>
    <?php endwhile;?>

    After this domtab, I am placing my comments_template(); part.

    The problem lies here - As I have used database query to display featured posts, it seems my normal post id is lost and the LAST POST'S (from featured list) POST ID IS USED TO DISPLAY COMMENTS. This is resulting in the comment section of the bottommost featured post.

    I googled on the problem and found one good result here:

    but I am not able to understand where to declare $id global and how to code near comments_template part.

    Kindly help me in a clear way as I am not a very good coder.

    Your help is appreciated. Thank you :)

  2. Justin Tadlock
    WordPress God
    Posted 7 years ago #

    Directly after the code you posted above, try adding this:

    <?php wp_reset_query(); ?>
  3. techpavan
    Posted 7 years ago #


    Thank you ... but I got it fixed by changing the query into fetching the feed of that category...

  4. Marcomail
    Posted 7 years ago #

    i have the same problem. could you explain me better your solution ? thanks

  5. techpavan
    Posted 7 years ago #

    Those who have same problem, you may use the solution I used...


    Use this with your category feed...

  6. Marcomail
    Posted 7 years ago #

    thanks, but i've solved moving <?php comments_template(); ?> outside the main loop


Topic Closed

This topic has been closed to new replies.

About this Topic