Support » Fixing WordPress » Stop posts loop and start page content loop

  • Resolved nicoliver



    I have created a custom page template in WP.
    Within this page I have created a query that displays all posts from a specific category. What I would now like to do is place the original page content + comments at the bottom.

    For some reason it is showing the titles from the previous query loop.
    This is the page:

    I have tried a few various options like wp_reset_query and defining parameters for a new loop but none seem to work.

    Does anyone have a suggestion on how I might go about stopping the first loop and then loading the pages content?


Viewing 2 replies - 1 through 2 (of 2 total)
  • Try a variation of this.
          'category__in' = array(7,45),
          'showposts' => 5,
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo '5 recent Posts';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        } //if ($my_query)
      wp_reset_query();  // Restore global post data stomped by the_post().

    You’re a genius! Thank you so much!!
    Been trying to solve this for ages.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Stop posts loop and start page content loop’ is closed to new replies.