having problem with multiple loops. – newest post is on every page
-
Hi,
I have been learning multiple loops. it seems relatively straight forward, and i have got it to work.
1st loop takes the newest “featured” post and displays it with different css. 2nd loop pulls in the remaining posts like normal. all working fine.
however when you get to the 2nd page, i want it to display older posts like it should. the problem is that the newest “feature” post is on the top of each page now and i don’t want this.
i have scoured for info and i have been given some code but i don’t know how to implement it. i feel like an idiot but i have been trying for over a week and still don’t get it…
i was given this to check if it’s page 1 or not but i don’t know how it works with the rest of my code…
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; if ($paged < 2) { // DO STUFF } ?>
please can someone help me to make this work? when i have learned this i want to start helping other people on this forum and give something back!!
this is my code
<?php get_header(); ?> <div class="top"></div> <div id="main-content"> <div class="loop"> <?php $my_query = new WP_Query('category_name=featured&posts_per_page=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?> <div id="datebox"> <p class="day"><?php the_time('d') ?></p> <p class="month"><?php the_time('M') ?></p> <p class="year"><?php the_time('Y') ?></p> </div> <div class="star"></div> <div class="clear"></div> <div id="post-<?php the_ID(); ?>"> </div> <!-- did wierd stuff with this when i moved "loop" up! --> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?></a></h2> <?php the_content('Read The Article / Have your say!'); ?> <!-- <p><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> </p> --> </div> <br /> <br /> <div class="shroom"></div> <br /> <br /> <br /> <?php endwhile; ?> <?php if (have_posts()) : while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?> <div id="datebox"> <p class="day"><?php the_time('d') ?></p> <p class="month"><?php the_time('M') ?></p> <p class="year"><?php the_time('Y') ?></p> </div> <div class="star"></div> <div class="clear"></div> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <?php the_title(); ?></a></h2> <?php the_content('Read The Article / Have your say!'); ?> <!-- <p><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> --> <br /> <br /> <div class="shroom"></div> <br /> <br /> <br /> </div> <?php endwhile; ?> <ul> <li><?php next_posts_link('Newer Entries »') ?></li> <li><?php previous_posts_link('« Older Entries') ?></li> </ul> <?php else : ?> <h2>Not Found</h2> <p>Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>
- The topic ‘having problem with multiple loops. – newest post is on every page’ is closed to new replies.