WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. techpavan
    Member
    Posted 5 years ago #

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

  2. Justin Tadlock
    Member
    Posted 5 years ago #

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

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

    @greenshady,

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

  4. Marcomail
    Member
    Posted 5 years ago #

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

  5. techpavan
    Member
    Posted 5 years ago #

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

    http://wphacks.com/how-to-adding-an-external-rss-feed-to-your-wordpress-blog/

    Use this with your category feed...

  6. Marcomail
    Member
    Posted 5 years ago #

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

    bye

Topic Closed

This topic has been closed to new replies.

About this Topic