Title: Header  have_post problem
Last modified: August 20, 2016

---

# Header have_post problem

 *  Resolved [meets](https://wordpress.org/support/users/meets/)
 * (@meets)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/header-have_post-problem/)
 * Hi every one,
 *  i am using have post in my header but when i go to my category it’s showing 
   only one category post on all category post . please any one help to me sort 
   out this problem. i am using below code
 *     ```
       <?php	
   
       query_posts('showposts=2&cat=12');
       if (have_posts()) :
       $i=0;
       while (have_posts()) : the_post();
       ?>
       ```
   
 * Thanks in advance.

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/header-have_post-problem/#post-3148308)
 * don’t use ‘query_posts()’ for secondary loops;
 * use `get_posts()` or `WP_Query()`
 * [http://codex.wordpress.org/Class_Reference/WP_Query](http://codex.wordpress.org/Class_Reference/WP_Query)
   
   [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)
 * and always make sure to reset the query after the secondary loop.
 * [http://codex.wordpress.org/Function_Reference/wp_reset_postdata](http://codex.wordpress.org/Function_Reference/wp_reset_postdata)
 * example:
 *     ```
       <?php	
   
       $header_posts = new WP_Query('posts_per_page=2&cat=12');
       if ($header_posts->have_posts()) :
       $i=0;
       while ($header_posts->have_posts()) : $header_posts->the_post();
       ?>
       YOUR OUTPUT
       <?php endwhile; endif; wp_reset_postdata(); ?>
       ```
   
 *  Thread Starter [meets](https://wordpress.org/support/users/meets/)
 * (@meets)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/header-have_post-problem/#post-3148317)
 * Thanks a lot Alchymyth.

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

The topic ‘Header have_post problem’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [meets](https://wordpress.org/support/users/meets/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/header-have_post-problem/#post-3148317)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
