• Resolved Drew Jaynes

    (@drewapicture)


    Background:

    I’m modifying the default loop in an author archive to display multiple post types with post formats enabled. I tried using a tax_query to exclude several of the formats from the query but I can’t get it to work. $paged is properly defined higher up.

    Anybody see anything wrong with this code block?

    $exclude_terms = array(
    	array(
    		'taxonomy' => 'post_format',
    		'field' => 'slug',
    		'terms' => array( 'post-format-quote', 'post-format-status', 'post-format-video' ),
    		'compare' => 'NOT IN'
    	)
    );
    
    query_posts( $query_string . '&posts_per_page=10&post_type=any&paged=' . $paged . '&tax_query=' . $exclude_terms );
Viewing 1 replies (of 1 total)
  • Thread Starter Drew Jaynes

    (@drewapicture)

    After a bit of tinkering, I finally got it working. Big changes were namely changing ‘compare’ to ‘operator’ in tax_query and passing in the other parameters as part of the $exclude_terms array.

    $exclude_terms = array(
    	'post_type' => 'any',
    	'author' => $author_id,
    	'posts_per_page' => 10,
    	'paged' => $paged,
    	'tax_query' => array(
    		array(
    		'taxonomy' => 'post_format',
    		'field' => 'slug',
    		'terms' => array( 'post-format-link', 'post-format-status' ),
    		'operator' => 'NOT IN'
    		)
    	)
    );
    
    query_posts( $exclude_terms );
Viewing 1 replies (of 1 total)
  • The topic ‘Having trouble with tax_query in query_posts’ is closed to new replies.