Issue I’m having is returning some data in a sidebar depending on which category the user is in. As of now I’m populating some thumbnails from ‘Press’ category in the sidebar, which is proving to be problematic. This is due to after I Query (from ‘Press’ cate) the thumbnails I want to pull, I notice it keeps me from accessing the current ‘Blog’ cate Query. How do I return back to the current category query?
<?php the_category(', ') ?> // This Returns 'Blog'
<?php
$args = array( 'numberposts' => 2, 'category' => 4);
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<div>generic return values</div>
<?php endforeach; ?>
<?php the_category(', ') ?> // This Returns 'Press', I want this to return 'Blog'
A call to wp_reset_query should get everything working for you again: