1

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.)

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.

1 Answer 1

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 );
1
  • Of course I massively overcomplicated that problem. Worked like a charm. Thanks! Commented Mar 15, 2013 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.