richarduk
Member
Posted 2 years ago #
I want to use multiple loops on a Page (page.php) and a single post (single.php) - the main loop for content, other loops in the footer
<?php $loop1 = new WP_Query();?>
<?php if ($loop1->have_posts()) : while ($loop1->have_posts()) : $loop1->the_post(); ?>
DO STUFF
<?php endif; ?>
<?php wp_reset_query();?>
I'm thinking of something like this for the main loop, but I've tested it and it doesn't work.
Nor does <?php $loop1 = new WP_Query(array('orderby' => DESC));?>
Clearly I'm going in the wrong direction.
Anyone have any ideas?
Thanks.
richarduk,
Your first loop on either single.php or page.php:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
DO STUFF
<?php endwhile; endif; ?>
The each successive loop on the page.php should be specific as to either category, or a specific post or page id:
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=6&showposts=5&paged=$page");
while ( have_posts() ) : the_post() ?>
DO STUFF
<?php endwhile; ?>
Is this what you are looking for or am I way off?
richarduk
Member
Posted 2 years ago #
Thanks doc4.
I had a mental block and you put me back on track.
I believe I'll need to use <?php wp_reset_query();?> before second or third loops etc. even though there's no WP_Query or query_posts before the first Page loop.
I'm guessing the second and third loops will need WP_Query before them ...
Anyhow, it's working again now and I shall continue experimenting