• Hi,

    I’m new to WP and I’ve spent the weekend trying to hack together my own theme, based on the default Kubrick theme.

    It was all going swimmingly until I realised that the four test comments that I’d set up are appearing on every post’s single post view, even though all four comments were added to only the first (of three test posts) post.

    As far as I can see my version of “single post” calls the comments in the same way as the default theme, and my version of comments has the same logic (if different display mark up).

    Could someone confirm that this:
    <?php comments_template(); ?>

    is the correct way to get the comments for the post being seen?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter cheezepie

    (@cheezepie)

    OK, I think I’ve worked this out.

    For reference I’m using the following code to display the most recent 3 posts in a side menu on the single post page:

    <h2>Most recent articles</h2>
    <ul>
    <?php global $post;
     $myposts = get_posts('numberposts=3&offset=0');
     foreach($myposts as $post) :?>
       <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <?php the_time('F jS, Y') ?>
       </li>
     <?php endforeach; ?>
    </ul>

    I’m guessing this is resetting the ID of the currently viewed post to all of the last three, one of which in this case has four comments and hence they are displayed.

    I guess I’ll have to rework my layout so the code above is not run during the loop. Or does anyone know a way of modifying the above so it doesn’t affect the ID of the current post? Thanks.

    I’m having the same problem – trying to call recent posts on a single post page imports all of their comments as well. Really having a tough time figuring this one out!

    Here is the code responsible – in my single.php

    <ul>
     <?php global $post; $myposts = get_posts('numberposts=5&offset=1');
     foreach($myposts as $post) :
     ?>
     <?php if (in_category('3')) continue; ?>
    <li><lid><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></lid></li>
    <?php endforeach; ?>
     </ul>

    I really hope someone can help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘One post’s comments appear on every post’s archive page’ is closed to new replies.