Using Query Posts With Multiple Post Types And A Taxonomy

not sure if you’ll have tried this yet but you could consider grabbing the two sets of posts separately then merging them. Finally use get_posts to create a combined list sorted the way you want. Something like this might work for you (you may want to add in a posts per page argument to the $args variables):

<?php
$sketchpad_args = array(
    'post_type' => 'sketchpad',
    'taxonomy'  => 'type',
    'term'      => 'public'
);
$sketchpad_posts = get_posts( $sketchpad_args );

$article_args = array(
    'post_type' => 'article',
);
$article_posts = get_posts( $article_args );

$all_posts = array_merge( $sketchpad_posts, $article_posts );

$post_ids = wp_list_pluck( $all_posts, 'ID' );//Just get IDs from post objects

// Do a new query with these IDs to get a properly-sorted list of posts
$posts = get_posts( array(
    'post__in'    => $post_ids,
    'post_status' => 'publish',
    'orderby' => 'date',
    'order' => 'ASC'
) );

foreach( $posts as $post ) :   
setup_postdata($post); ?>

// Your loop stuff

<?php endforeach; ?>

Leave a Comment