[Resolved] Help with multiple loops, WP_Query and while statement!
Will try and describe my issue as accurately as possible with my limited skills. I am building a football/soccer magazine style theme, where the home.php page displays a splash area which loads the latest post of a particular category. Underneath this splash area, are three further boxes which in turn show the latest post of 3 categories.
For instance, (this is a football site which will be covering different leagues and countries), the main splash area will show the most recent post from England. Underneath this will be a holding area for each Spain, Italy and again England which will display the latest post for each respective category.
In the case of the England category, I obviously wouldn’t want to repeat the same post twice, so I would like to show the next most recent post.
I am using the following code to display the top article:
<?php $my_query = new WP_Query('category_name=England&posts_per_page=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?>
I am doing something similar for Spain and Italy also. I am having problems with knowing how to write the code for the block that will show the next England post, for it not to display the same post in the area above.
<?php $my_query_england = new WP_Query('category_name=England&posts_per_page=1'); while ($my_query_england->have_posts()) : $my_query_england->the_post(); ?>
I guess I need some code in that while section to say if the next post is not equal to $do_not_duplicate.
here is what the page will look like in terms of structure for visual purposes… http://farm5.static.flickr.com/4004/4402683460_f86e75fa92_o.jpg
I hope someone can point me in the right direction!
- The topic ‘[Resolved] Help with multiple loops, WP_Query and while statement!’ is closed to new replies.