Title: WP Loop Help
Last modified: August 19, 2016

---

# WP Loop Help

 *  Resolved [theros](https://wordpress.org/support/users/theros/)
 * (@theros)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/wp-loop-help/)
 * Hey there!
 * I need some help on fixing the WP Loop. On this page [here](http://www.cristianavk.com),
   there are supposed to be 3 loops, one that shows the most recent post at the 
   top regardless of what category. And the other two show the most recent post 
   from either the Books or Wine/Food categories, also making sure not to repeat
   posts.
 * However, I can’t get the bottom two loops to show that. I have 3 posts up, one
   for each category (uncategorized, books, and winefood) and yet only the winefood
   one is showing up?
 * How can I fix this?
 * The bottom two WP loop code:
 *     ```
       <div class="indextitles">
       <div class="titlebooks">Latest Books</div>
       <div class="fw">Latest Food/Wine</div>
       </div>
       <div id="indexcontent">
       <?php $mycats = array(3,4); // the category ID numbers
       foreach ($mycats as $catid) :
       query_posts(array('cat'=>$catid,'showposts'=>2));
       $x=0;
       	while (have_posts()): the_post();
       		if ($post->ID != $do_not_duplicate && $x < 1)
       			{	?>
       			<div class="index" id="post-<?php the_ID(); ?>">
       				<div class="date"><?php the_time('F jS, Y') ?></div>
       				<div class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
   
       					<?php the_excerpt();?>
       					<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Read more...</a>
       				<?php
       				$x++;
       				echo "</div>";
       			}
       endwhile;
       endforeach;?>
       </div>
       ```
   
 * Thanks,
    Eric Huang
 * *EDIT* Sorry, just realized that. Fixed it. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [17 years, 5 months ago](https://wordpress.org/support/topic/wp-loop-help/#post-884097)
 * Code. Post your code. We can’t see it unless you post it.
 *  Thread Starter [theros](https://wordpress.org/support/users/theros/)
 * (@theros)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/wp-loop-help/#post-884098)
 * Oops…that was a stupid mistake by me. I needed a total of 4 books to show that
   loop.
 * Thanks,
    Eric Huang
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [17 years, 5 months ago](https://wordpress.org/support/topic/wp-loop-help/#post-884205)
 * Well, that is some unusual code, but there is nothing really wrong with it. Make
   sure you got the category ID numbers correct.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘WP Loop Help’ is closed to new replies.

## Tags

 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/wp-loop-help/#post-884205)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
