Display all posts for taxonomy term across multiple custom post types

I’m currently creating a website that uses several content types, (e.g. books, movies, shows) as well as a key taxonomy term (e.g. status, with values of owned and wishlist).

My question is, in a custom template how do I create a loop that queries only one taxonomy value across multiple custom post types (i.e. a single list of all of the books, movies and shows on my wishlist.)

Read More

The closest I could find was this post Using Query Posts With Multiple Post Types And A Taxonomy

But unfortunately, I am having a hard time making it work as is in my template. And, ideally I’d prefer to use a wp_query instead of get_posts.

Related posts

Leave a Reply

1 comment

  1. You can do this with an array of post types and a tax query for your term. The question you linked had special requirements as only one of the post types used the taxonomy.

    $args = array(
        'post_type' => array( 'books', 'movies', 'shows' ),
        'posts_per_page' => -1,
        'tax_query' => array(
            array(
                'taxonomy' => 'status',
                'field' => 'slug',
                'terms' => 'wishlist'
            )
        )
    );
    $wishlist = new WP_Query( $args );