Loop within a loop - wordpress
<p>On the page that displays a single post, I also wish to display some featured posts.</p>

<p>The featured posts have a meta value assigned to them to differentiate between featured and non featured posts.</p>

<p>The problem is that I wish to display the featured posts half way down my page but the loop starts at the top and doesn't finish until the bottom of the page.</p>

<p>From WP docs: </p>

<pre><code>&lt;?php
    // The main query.
    if (have_posts()) {
      while (have_posts()) {
        the_post();
        the_title();                                                             
        the_content();                                                          
      } # End while loop                                                             
    } else {                                                                      
        // When no posts are found, output this text.                           
        _e( 'Sorry, no posts matched your criteria.' );                         
    }                                                                  
    wp_reset_postdata();                                                        

    /*                                                                          
     * The secondary query. Note that you can use any category name here. In our example,
     * we use "example-category".                                               
    */                                                                        

    $secondary_query = new WP_Query( 'category_name=example-category' );        

      // The second loop. 
    if ($secondary_query-&gt;have_posts()) {
      echo '&lt;ul&gt;';
        // While loop to add the list elements.
        while ($secondary_query-&gt;have_posts()) {
            $secondary_query-&gt;the_post();
            echo '&lt;li&gt;' . get_the_title() . '&lt;/li&gt;';
        }
      echo '&lt;/ul&gt;';
    }
wp_reset_postdata();
?&gt;
</code></pre>

<p>At the end of the first loop, you have to call <code>wp_reset_postdata()</code> but in my scenario, there is data that needs to be retrieved further down the page so I can't end it there. </p>

<p>I essentially need to do this but then only the featured posts get rendered and not the post itself.</p>

<pre><code>if (have_posts()) {

    while (have_posts()) { 
      the_post();
      the_title();                                                             
      the_content();                                                         

      //Display featured posts half way through
      $secondary_query = new WP_Query( 'category_name=example-category' );
      //end featured post loop
      wp_reset_postdata(); 

      //continue outputting data from first loop 
      the_title();
    } # End while loop.                                                                 

} else {                                                     
    // When no posts are found, output this text.                           
    _e( 'Sorry, no posts matched your criteria.' );                         
}

//finally end inital loop                                                        
wp_reset_postdata(); 
</code></pre>

<p>Is it possible to 'pause' the loop to do a different loop then pick it back up again later on?</p>