WordPress.org

Ready to get started?Download WordPress

Forums

WP_Query issue within sidebar (4 posts)

  1. rblasko
    Member
    Posted 4 years ago #

    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>
  2. MichaelH
    Member
    Posted 4 years ago #

    If you change $exfeat to an actual category does it work?

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

  3. rblasko
    Member
    Posted 4 years ago #

    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;
    				?>
  4. MichaelH
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic