WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] comments_template not working on single.php

[Resolved] comments_template not working on single.php

  • Hi,

    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:
    http://www.mydigitallife.info/2006/06/24/retrieve-and-get-wordpress-post-id-outside-the-loop-as-php-variable/

    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 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] comments_template not working on single.php’ is closed to new replies.