Title: Problem with loop returning posts
Last modified: August 19, 2016

---

# Problem with loop returning posts

 *  [phantomsd](https://wordpress.org/support/users/phantomsd/)
 * (@phantomsd)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problem-with-loop-returning-posts/)
 * Hey guys,
 * I have a custom category page ([http://example.com/wordpress/?cat=83](http://example.com/wordpress/?cat=83))
   and in the code for that category I have a custom wp query loop. The problem 
   is… the loop just returns “Not found” instead of my posts.
 * BUT when I copy and paste the same exact code and save it as index.php… the posts
   magically appear as they’re suppose to.
 * Is there something I’m missing or doing wrong? Some rule I might be overlooking?
 * HELP!
 * Thanks in advance!!!

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problem-with-loop-returning-posts/#post-1289521)
 * Well put the complete template code in a pastebin and report the link back here
   and maybe someone can spot the problem.
 *  Thread Starter [phantomsd](https://wordpress.org/support/users/phantomsd/)
 * (@phantomsd)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problem-with-loop-returning-posts/#post-1289523)
 *     ```
       <?php include ('header2.php'); ?>
   
       <div id="container">
   
       <div class="container_content">
   
       	<div class="featured_a">
   
       	<?php $featured_a = new WP_Query();
       	$featured_a->query('cat=10&showposts=1');
       	?>
   
       	<?php if(have_posts()) : ?><?php while($featured_a->have_posts()) : $featured_a->the_post(); ?>
   
       		<div class="post_featured" id="post-<?php the_ID(); ?>">
   
       			<?php $image = get_post_meta($post->ID, 'featured_image', true); ?>
   
       			<a href="<?php the_permalink() ?>"><img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" /></a>
   
       			<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
   
       			<?php the_excerpt(); ?>
   
       		</div>
   
       	<?php endwhile; ?>
   
       	<?php else : ?>
   
       		<div class="post_featured">
       			<?php _e('Not Found'); ?>
       		</div>
   
       	<?php endif; ?>
   
       	</div>
   
       	<div class="featured_b">
   
       	<?php $featured_b = new WP_Query();
       	$featured_b->query('cat=10&showposts=1&offset=1');
       	?>
   
       	<?php if(have_posts()) : ?><?php while($featured_b->have_posts()) : $featured_b->the_post(); ?>
   
       		<div class="post_featured" id="post-<?php the_ID(); ?>">
   
       			<?php $image = get_post_meta($post->ID, 'featured_image', true); ?>
   
       			<a href="<?php the_permalink() ?>"><img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" /></a>
   
       			<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
   
       			<?php the_excerpt(); ?>
   
       		</div>
   
       	<?php endwhile; ?>
   
       	<?php else : ?>
   
       		<div class="post_featured">
       			<?php _e('Not Found'); ?>
       		</div>
   
       	<?php endif; ?>
   
       	</div>
   
       	<div class="featured_c">
   
       	<?php $featured_c = new WP_Query();
       	$featured_c->query('cat=10&showposts=1&offset=2');
       	?>
   
       	<?php if(have_posts()) : ?><?php while($featured_c->have_posts()) : $featured_c->the_post(); ?>
   
       		<div class="post_featured" id="post-<?php the_ID(); ?>">
   
       			<?php $image = get_post_meta($post->ID, 'featured_image', true); ?>
   
       			<a href="<?php the_permalink() ?>"><img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" /></a>
   
       			<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
   
       			<?php the_excerpt(); ?>
   
       		</div>
   
       	<?php endwhile; ?>
   
       	<?php else : ?>
   
       		<div class="post_featured">
       			<?php _e('Not Found'); ?>
       		</div>
   
       	<?php endif; ?>
   
       	</div>
   
       </div>
   
       </div>
   
       <div class="push"></div>
   
       </div>
   
       <?php get_footer(); ?>
   
       </body>
       </html>
       ```
   
 *  Thread Starter [phantomsd](https://wordpress.org/support/users/phantomsd/)
 * (@phantomsd)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problem-with-loop-returning-posts/#post-1289633)
 * Any ideas?
 * (Happy Thanksgiving, everyone!)
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/problem-with-loop-returning-posts/#post-1289695)
 * Didn’t check everything, but at a quick glance shouldn’t something like this:
 *     ```
       <?php if(have_posts()) : ?><?php while($featured_a->have_posts()
       ```
   
 * show be:
 *     ```
       <?php if($featured_a->have_posts()) : ?><?php while($featured_a->have_posts()
       ```
   
 * So you would need to fix that for each of your loops.
 * Also note that `get_header('2')` will include header-2.php
 * And typically `</body>` and `</html>` are in the footer.php template.

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

The topic ‘Problem with loop returning posts’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/problem-with-loop-returning-posts/#post-1289695)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
