Title: WP_Query issue within sidebar
Last modified: August 19, 2016

---

# WP_Query issue within sidebar

 *  [rblasko](https://wordpress.org/support/users/rblasko/)
 * (@rblasko)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/wp_query-issue-within-sidebar/)
 * I have a a “featured post box” within my sidebar (it’s displayed immediately 
   underneath the Google map [here](http://vagabond3.com)). For some reason – on
   the homepage only – it is not listing any posts within the Featured tab. If you
   navigate to another page – for example, [here](http://vagabond3.com/topics/onlocation/)–
   you’ll see that it’s pulling posts into the Featured tab without any issue. The
   code for this is directly in my sidebar.php file, and thus it’s identical for
   each page on the site and shouldn’t differ, right? I did notice that the code
   used to pull actual posts onto the pages is different – on the homepage, it’s
   a WP_Query, and on other pages, it’s have_posts. Could definitely use some help
   troubleshooting this issue. Thanks!
 * Here’s the code used to pull this feature:
 *     ```
       <ul class="list1" id="feat">
       				<?php
       					include(TEMPLATEPATH . '/includes/version.php');
       					$the_query = new WP_Query('cat=' . $ex_feat  . '&showposts=10&orderby=date&order=asc');
       					while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
       				?>
   
       					<li><a title="Permanent Link to <?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
   
       				<?php endwhile; ?>
       			</ul>
       ```
   

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/wp_query-issue-within-sidebar/#post-1355541)
 * If you change $exfeat to an actual category does it work?
 * Note: not sure why you would need that include statement…
 *  Thread Starter [rblasko](https://wordpress.org/support/users/rblasko/)
 * (@rblasko)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/wp_query-issue-within-sidebar/#post-1355620)
 * I tried changing the code as shown below. It’s still outputting correctly on 
   every page but the homepage, where it’s still not pulling any posts. So confused…
 *     ```
       <?php
       					$the_query = new WP_Query('cat=7&showposts=10&orderby=date&order=asc');
       					while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
       				?>
       ```
   
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/wp_query-issue-within-sidebar/#post-1355664)
 * Please paste all the code from the theme template file (probably sidebar.php)
   that is displaying those posts into a pastebin such as [wordpress.pastebin.ca](http://wordpress.pastebin.ca),
   and report the link back here. Maybe someone can spot your problem. Thanks.

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

The topic ‘WP_Query issue within sidebar’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/wp_query-issue-within-sidebar/#post-1355664)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
