• I have a page where I need to display posts with a custom meta key value of “original-document” in the left column and the rest of the posts from the category in the right column. You can see the page here http://www.constitutingamerica.org/blog/classification/the-federalist-papers/federalist-no-23/

    The problem is that the posts tagged as original documents are showing up in the right column as well as the left column.

    global $query_string;
    $keys = array(
    		'orderby' => 'ID',
    		'order' => 'asc',
     		'numberposts' => -1,
    		'meta_query' => array(
            	array  (
                	'key' => 'document_details',
                	'value'=>'original-document'
            		)
    			)
    		);
    
    $args = array_merge( $wp_query->query_vars, $keys );
    
    $keys2 = array(
     		'orderby' => 'ID',
    		'numberposts' => -1,
    		'post__not_in' => array($args),
    		'order' => 'asc',
    		'meta_query' => array(
            	array  (
                	'meta_key' =>	'document_details',
                	'meta_value' =>	'original-document',
    			'meta_compare' => '!='
            		)
    			)
    		);
    
    $args2 = array_merge( $wp_query->query_vars, $keys2	 ); ?>

    I have also tried excludes and operators in my $args2 query and the original documents still show. I also though this would work in my second query but it does not work

    $keys2 = array(
     		'orderby' => 'ID',
    		'numberposts' => -1,
                    'exclude' => array($args),
    		'post__not_in' => array($args),
    		'order' => 'asc',
    		);
    
    $args2 = array_merge( $wp_query->query_vars, $keys2	 ); ?>

    How can I exclude any posts from my first query from appearing in my second query?

The topic ‘Exclude posts from one query in another query’ is closed to new replies.