Untested – Get posts with variable taxonomy terms

 

$tax = 'music';
$oterm = 'pop';
$term = get_term_by('slug', $oterm, $tax);
$termChildren = get_term_children($term->term_id, $tax);
$wp_query = new WP_Query();
$wp_query->query(
	array(
		'posts_per_page' => '5',
		'tax_query' => array(
			array(
				'taxonomy' => $tax,
				'field' => 'slug',
				'terms' => $oterm
			),
			array(
				'taxonomy' => $tax,
				'field' => 'id',
				'terms' => $termChildren,
				'operator' => 'NOT IN'
			)
		)
	)
);

Revisions

There are no revisions for this post.

Tags:

No comments yet.

Leave a Reply