[resolved] query in sidebar conflicting with main query on page (2 posts)

  1. Skeary
    Posted 3 years ago #

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

    			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; ?>
    			<?php endif; ?>
    			<?php wp_reset_postdata(); ?>
  2. Skeary
    Posted 3 years ago #

    Looks like get_posts() was the way to go.

    I would have rather gone by category name, but this will have to do.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.