On a taxonomy archive, how does one create multiple loops for different post types that share that taxonomy? I’m using taxonomy-themes.php so that it applies to all three of the terms in the ‘themes’ taxonomy (climate change, governance, peace building).
On each term’s archive page, I want to output the main taxonomy loop (posts), and then I want to create loops for each of ‘events’, ‘resources’ and ‘staff’ (all of which are custom post types). I’m assuming that I create new wp_query for each of the post types, but how do I tell that query which term I want it to get ‘events’ from (ie. the current archives‘ term)?
As you point out, if you want separate loops for different post types you’ll need to use a separate
WP_Query() for post type. In the template you can get the current term (ID) being viewed via:
get_queried_object_id() (see source)
$args = array( 'post_type' => 'staff', 'tax_query' => array( array( 'taxonomy' => 'themes', 'terms' => get_queried_object_id(), 'field' => 'id' ) ), ); $staff = WP_Query( $args );