Add in dual loop into single loop
php-brief
last edit: Dec, 2nd 2011 | jump to bottom
<?php $wp_query = new WP_Query(); $per_page=$paged<=1?7:8; $wp_query->query('posts_per_page='.$per_page.'&paged='.$paged); if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post(); // Check if paged if ($paged<=1) { ?> <!-- LOOP NEWS POST --> <div class="arc-mod" > <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" class="arc-mod-title"> <?php the_title(); ?> </a> <div class="arc-mod-meta"> <span>//</span> Posted By <a href="/blog/index.php?author=<?php the_author_ID(); ?>"><?php the_author_nickname(); ?></a> on <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_time('jS F Y') ?></a> | <span class="arc-mod-ilove"><?php if(function_exists(getILikeThis)) getILikeThis('get'); ?></span> </div> <div class="arc-mod-content"> <div class="arc-mod-excerpt"> <?php new_excerpt(500); ?> </div> <div class="arc-mod-center"> <a href="<?php the_permalink() ?>" title="Real Full Article" class="arc-mod-img-link"> <img src="<?php bloginfo('template_url'); ?>/images/photos/test.jpg" alt="<?php the_title(); ?>" /> </a> </div> </div> </div> <?php }; break; // break the loop endwhile; ?> <?php // Rewind the loop $wp_query->rewind_posts(); // set the iterator $i=1; ?> <div class="equal-height"> <?php // loop again while ($wp_query->have_posts()) : $wp_query->the_post(); // check if it is even then skip $c = $i % 2; if ( $c === 0 ) continue; ?> <!-- LOOP AFTER POSTS --> <div class="midi-arc-mod" > <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <?php the_title(); ?> </a> <div class="midi-arc-mod-meta"> Posted By <a href="/blog/index.php?author=<?php the_author_ID(); ?>"><?php the_author_nickname(); ?></a> </div> <div class="midi-arc-mod-content"> <div class="midi-arc-mod-excerpt"> <a href="<?php the_permalink() ?>"> <img src="test.jpg" alt="<?php the_title(); ?>" /> </a> <?php new_excerpt(500); ?> </div> </div> </div> <?php $i++; endwhile; ?> <!-- END SPLIT LOOP 1 --> <?php // Rewind the loop $wp_query->rewind_posts(); // set the iterator $i=1; ?> <div class="equal-height"></div> <!-- SPLIT LOOP 1 RETURNS 1, 3, 5 --> <?php // loop again while ($wp_query->have_posts()) : $wp_query->the_post(); // check if it is even then skip $c = $i % 2; if ( $c === 0 ) continue; ?> <div class="midi-arc-mod" > <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <?php the_title(); ?> </a> <div class="midi-arc-mod-meta"> Posted By <a href="/blog/index.php?author=<?php the_author_ID(); ?>"><?php the_author_nickname(); ?></a></span> </div> <div class="midi-arc-mod-content"> <div class="midi-arc-mod-excerpt"> <a href="<?php the_permalink() ?>"> <img src="test.jpg" alt="<?php the_title(); ?>" /> </a> <?php new_excerpt(500); ?> </div> </div> <div class="midi-arc-mod-foot"> <a href="<?php the_permalink() ?>"><span>//</span> Read Full Article</a> </div> </div> <?php $i++; endwhile; ?> <!-- END SPLIT LOOP 1 --> <?php $wp_query->rewind_posts(); //Rewind the loop ?> <?php // reset the iterator $i = 1; while ($wp_query->have_posts()) : $wp_query->the_post(); // check if it is odd then skip if ( $i % 2 ) continue; ?> <div class="midi-arc-mod" > <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <?php the_title(); ?> </a> <div class="midi-arc-mod-meta"> Posted By <a href="/blog/index.php?author=<?php the_author_ID(); ?>"><?php the_author_nickname(); ?></a></span> </div> <div class="midi-arc-mod-content"> <div class="midi-arc-mod-excerpt"> <a href="<?php the_permalink() ?>"> <img src="test.jpg" alt="<?php the_title(); ?>" /> </a> <?php new_excerpt(500); ?> </div> </div> <div class="midi-arc-mod-foot"> <a href="<?php the_permalink() ?>"><span>//</span> Read Full Article</a> </div> </div> <?php $i++; endwhile; ?> <!-- END SPLIT LOOP 2 --> </div><!-- end equal height div --> <?php $i++; endwhile; ?> <div class="previous-link"><?php next_posts_link(__('<span>//</span> PREVIOUS STORIES')) ?></div> <div class="next-link"><?php previous_posts_link(__('<span>//</span> NEWER STORYS')) ?></div> <?php endif; ?>
79 views




