[resolved] Stop posts loop and start page content loop (3 posts)

  1. nicoliver
    Posted 6 years ago #


    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: http://dinky.nicholasoliver.co.uk/

    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?


  2. MichaelH
    Posted 6 years ago #

    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().
  3. nicoliver
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic