Multiple post type queries (with specific arguments for each)

So i know how to combine post types into 1 loop and out put the loop. Below is what i have:

        <?php

        $args = array(
            'post_type' => array('post','movie','actor'),
            'posts_per_page' => '20',
        );

        query_posts( $args );
        while ( have_posts() ) : the_post(); 

            the_title();

        endwhile; 

        ?> 

This works as expected, however is it possible to specify different arguments for each post type, while keeping them within the same original loop.

Read More

So for example i need to add a meta_key=value argument to the movie & actor post types. Is this possible?

Related posts

Leave a Reply

1 comment

  1. Could you do something like this?

    <?php
    
        $args = array(
            'post_type' => array('post','movie','actor'),
            'posts_per_page' => '20',
        );
    
        query_posts( $args );
        while ( have_posts() ) : the_post(); 
    
            global $post;
    
            if (($post_type == 'movie') && (get_post_meta($post->ID, 'meta_key', true) == 'your-value')) {
    
                 // Display your content for Movie Post Type with meta value set
    
             } else if (($post_type == 'actor') && (get_post_meta($post->ID, 'meta_key', true) == 'your-other-value')) {     
    
                 // Display your content for Actor Post Type and Other Meta Value
    
             }    
    
        endwhile; 
    
        ?>