• I have a a “featured post box” within my sidebar (it’s displayed immediately underneath the Google map here). 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 – 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)
  • If you change $exfeat to an actual category does it work?

    Note: not sure why you would need that include statement…

    Thread Starter rblasko

    (@rblasko)

    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;
    				?>

    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, 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.