Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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 );
share|improve this answer
    
Of course I massively overcomplicated that problem. Worked like a charm. Thanks! –  Joey Mar 15 '13 at 19:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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