• stridz0r

    (@stridz0r)


    Hi, For design reasons, I had to call the comments.php outside of the loop. Problem is that the comments correspond to the latest post and not the current post. Obviously I need the comments to correspond with the current post.

    On my post.php I have the Loop, after the loop I have this code:

    <?php  $posts = get_posts('numberposts=4&offset=0&category=1');
            if ($posts) :
            foreach($posts as $post) :
            setup_postdata($post);
            ?>
              <div id="show_latest_posts">
              <a href="<?php the_permalink(); ?>">
              <img
                title="<?php the_title(); ?>"
                alt="<?php the_title(); ?>"
                src="<?php
                $customFields = get_post_custom();
                $thumbnail = $customFields['thumbnail'];
              if ($thumbnail) {
                print $thumbnail[0];
              } else {
                print bloginfo('stylesheet_directory')."/images/novideo.gif";
              }
              ?>" width="200" height="113" /><br /><?php the_title(); ?></a>
              </div>
            <?php endforeach; endif;?>

    What this does is call a thumbnail for each of the last 4 posts, this is happening right after the loop, then I call the comments. Tried several ways, but it still shows comments from the last post and not the current one. And when I comment, comments go also to the latest post and not the current one.

    Any advice?

Viewing 1 replies (of 1 total)
  • If I understand what you are doing I wouldn’t do it by creating another DB query. The initial $post variable already has the information you need. Just iterate over it a second time and only call the parts related to comments.

Viewing 1 replies (of 1 total)
  • The topic ‘Comments not correspond to current post’ is closed to new replies.