I want to use WP_Query and construct two queries that:
- show posts from TWO categories (eg: current category + ontop category)
- show posts from only the current category (ie, it can't appear in the "ontop" category)
Untested, but I think I can go about it like this:
// The query $category = get_the_category(); $the_query = new WP_Query( array( 'category__and' => array( $category, 286 ) ) ); // where 286 is the "ontop" category // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); do_old_loop(); endwhile; // The second query $the_query = new WP_Query( // This is my main question, how to include the query for this. // I want to include the current category, but exclude the category 286 ); // where 286 is the "ontop" category // The second loop while ( $the_query->have_posts() ) : $the_query->the_post(); do_old_loop(); endwhile; // Reset Post Data wp_reset_postdata();
- The do_old_loop function has the makeup of how the loop was originally constructed--I just wrapped it in a function so I could call it again (*the function just remains in the loop.php right below this code - is that ok? bad practise?
- Should the reset post data appear after each loop has run?
- how do I construct the second query???
This is where I am stuck, I can't work out how to create this. The reference at http://codex.wordpress.org/Class_Reference/WP_Query includes a lot of examples, but not this one.