i have a wordpress query:
$myPosts = new WP_Query();
$myPosts->query($queryArray);
How do i display these according to the loop template. I'm already inside a loop so this isn't working:
print get_template_part('loop');
Looping within a Loop is possible, and while you can technically still use your template loop.php, it's a bit of a pain because you have to set up the query differently. You're best of just leaving it in the file, or creating a function and passing the query to that function.
Any way, back to the question. First of all you need to make a copy of the current query so that you can go back to it after the second query -
$query_safe = $wp_query;
Now you need to setup your new loop and output what ever you want within it -
if($myPosts->have_posts()) : while($myPosts->have_posts()) : $myPosts->the_post();
<h2><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
endwhile;
endif;
Finally, when you are done, restore your original query so that WP can continue with that loop.
$wp_query = $query_safe;