My solution at the moment is to use a GET variable to request a different page template:
- Regular version of taxonomy page: mysite.com/subjects/science
- Blog version of taxonomy page: mysite.com/subjects/science?view=blog
To handle the ?view=blog variable, I add this conditional to the top of taxonomy.php (or taxonomy-subjects.php and any other taxonomy-{slug} that I want to have an alternate version of):
/****************************************************
Tell WordPress to fetch a different
template if our URL ends in ?view=blog
****************************************************/
$view = $_GET["view"];
if ( $view == "blog" ) {
get_template_part( 'blog-archive' );
exit();
}
Then, in the blog-archive.php template, I adjust the query_vars of $wp_query to output a loop with only blog posts.
// adjust $wp_query->query_vars to taste
$newloop = array_merge( $wp_query->query_vars, array( 'post_type' => 'blog', 'posts_per_page' => 5 ));
$the_query = new WP_Query ($newloop);
while ( $the_query->have_posts() ) : $the_query->the_post();
//output your posts however you like
endwhile;
wp_reset_postdata();
This works for me at the moment; the only unfortunate aspect is that the URLs show ?view=blog instead of nice /blog. I borrowed the main $_GET[] idea from the answer here: How can I dynamically load another page template to provide an alternate layout of the posts?. (I wonder if the latter can be done more intuitively with $the_query = $wp_query->set(‘post_type’, ‘blog’); but this seemed to turn $the_query into a non-object and give an error.)