• $post_type = 'ba-pet';
    $tax = 'status_ba';
    $tax_terms = get_terms($tax);
    
    	if ($tax_terms) {
    		foreach ($tax_terms  as $tax_term){
    			$args=array(
    				'post_type' => $post_type,
    	      			'tax_query' => array(array('taxonomy' => 'status_ba',
    						'field'    => 'slug',
    						'terms'    => array('available','pending'))),
    	      			"$tax" => $tax_term->slug,
    	      			'post_status' => 'publish',
    	      			'posts_per_page' => -1,
    	      			'caller_get_posts'=> 1
    				);
    			$my_query = null;
    			$my_query = new WP_Query($args); [...]

    The above code is what I have setup so far… I’m wanting to pull back posts from my taxonomy (status-ba) that has 5 terms in it, I only want to pull back a certain 2 taxonomies (available & pending).

    Currently it’s only pulling back ‘pending’, I have a post with ‘pending’ and one with ‘available’ statuses, so it should be pulling back both.

    What am I missing?

    Thanks

Viewing 1 replies (of 1 total)
  • Richard

    (@richardcoffee)

    You are using conflicting parameters and that is why it isn’t working for you. Try this instead:

    $args=array('post_type' => $post_type,
    	     'tax_query' => array(array('taxonomy' => 'status_ba',
    					'field'    => 'slug',
    					'terms'    => array('available','pending'))),
    	      			'post_status' => 'publish',
    	      			'posts_per_page' => -1,
    				);
    $my_query = new WP_Query($args);

    Also, I don’t believe you need that foreach loop, or at least it is not germane to the question.

Viewing 1 replies (of 1 total)
  • The topic ‘List posts only of specific terms from a custom taxonomy for wordpress’ is closed to new replies.