WordPress.org

Forums

tax_query not returning posts that multiple terms are applied to (2 posts)

  1. Jeffery Moore
    Member
    Posted 2 years ago #

    Hi, maybe I am misusing the tax_query parameter set, but here is my code:

    $posts = get_posts( array(
        'post_type' => get_post_type($current_id),
    	'tax_query' => array(
    		array(
    			'taxonomy' => $tax,
    			'terms' => $term_id,
    			'field' => 'id',
    			'operator' => 'IN',
    			'include_children' => true
    		)
    	)
    ) );

    What this is supposed to do is return all posts that belong to term $term_id of the custom taxonomy $tax. Seems simple enough and it does return such posts, except those that also belong to another term within the same taxonomy. It's maddening and either this is a bug or I am misunderstanding how the API works.

    Can someone please help me keep from pulling the rest of my hair out?

  2. dlozupone
    Member
    Posted 1 year ago #

    I am having this same problem. Did you get any solution to this?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags