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' ) );
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.
Are you a blogger, web designer, developer, or website owner looking to generate more income?
Promote products for the largest and fastest growing online website platform as part of our affiliate program.