I have this in my sidebar.php and it works, except that it overwrites the main query of the page and every time I just get the archive for the newsletter category. How can I stop it from doing that? What is the recommended way to get that data without interrupting the main loop? Do I need to use a wpdb query? seems like it shouldn’t need that..
<?php query_posts( 'category_name=newsletter' ); if ( $wp_query->have_posts() ) : ?> <select id="newsletter-dropdown" name="newsletter-dropdown"> <option value="">Newsletter Archives</option> <? while ( have_posts() ) : the_post(); ?> <option value="<?php the_permalink(); ?>"><?php the_title(); ?></option> <?php endwhile; ?> </select> <?php endif; ?> <?php wp_reset_postdata(); ?>
- The topic ‘query in sidebar conflicting with main query on page’ is closed to new replies.