• Hi,

    I’m using a plugin to execute PHP in pages so I can show a list of all posts in a category. This is the code I’m using:

    <div class="pgcontainer">
    <ul><?php $recent = new WP_Query("cat=994&showposts=100"); while($recent->have_posts()) : $recent->the_post();?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
    </div>

    The code works, but, if there are comments on the last item in the list, they are also displayed on the page. Obviously I don’t want this to be the case but I don’t know what’s causing it.

    Any advice is appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • the ‘comments_template()’ of the page template is probably picking up on the last post id in your code;

    try to add
    <?php wp_reset_query(); ?>
    after your code.

    Thread Starter digitali

    (@digitali)

    alchymyth, thank you! that did the trick.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Comments appear on page used to display list of posts – not sure why’ is closed to new replies.