I am trying to use the code below in functions.php with the goal of querying the database for one category. Works like a charm. I also am using code in the genesis_after_loop to reset the query via wp_reset_query(). Problem is the query is not being reset.
Can anyone shed some light on how I can reset the global query after the code below runs?
Thanks very much.
function dwz_staff_custom_fields_before_loop ()
$wp_query = null;
if( is_page(9781) OR is_category(43) ) // Meet Our Staff page as well as category archive page
query_posts( array( 'category__and' => array(43), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC' ) );
Web + WordPress
You would be better rewriting this to use the WP_query object rather than using query_posts. This will avoid having to reset the loop.
The two articles below will provide more information and pointers of how to do this.
I hope that's useful. Let me know if you need more assistance with this.
You must be logged in to reply to this topic.
Subscribe to get early access to new themes, discounts and brief updates about what's new with StudioPress!