Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

troyward on "Getting Term IDs in WP_Query"

$
0
0

I am trying to run a query to display posts from a custom post type that do not have any terms from a custom taxonomy associated with them. Here is the code.

$args = array(
'fields' => 'ids',
'orderby'=> 'id',
'order' => 'ASC',
'hideempty' => 0
);
$term_ids = get_terms( 'people', $args);

$args = array(
	'post_type' => 'organizations',
	'tax_query' => array(
		array(
		'taxonomy' => 'people',
		'terms' => $term_ids,
		'operator' => 'NOT IN'
		))
);

In the result I get entries from the first term id. So it seems like $term_ids is an array so it is probably getting only the first term id? But if it is getting the first term ID then it should not display posts from it. Instead it should display posts from other terms.

Please point out what I am doing wrong?


Viewing all articles
Browse latest Browse all 8245

Trending Articles