Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

WP query filtered by taxonomies

Retrieve posts filtered by taxonomies.

// WP_Query arguments
$args = array(
	'post_type'              => array( 'post' ),
	'post_status'            => array( 'publish' ),
	'orderby'                => 'date',
	'tax_query'              => array(
		'relation' => 'OR',
		array(
			'taxonomy'         => 'tags',
			'terms'            => array( 'Nasa', 'Space' ),
			'field'            => 'name',
			'operator'         => 'AND',
		),
		array(
			'relation' => 'AND',
			array(
				'taxonomy'         => 'category',
				'terms'            => 'spaceflight',
				'field'            => 'slug',
			),
			array(
				'taxonomy'         => 'section',
				'terms'            => 'Opinion',
				'field'            => 'name',
			),
			array(
				'taxonomy'         => 'post_format',
				'terms'            => array( 'post-format-video', 'post-format-audio' ),
				'field'            => 'slug',
				'operator'         => 'IN',
			),
		),
	),
);

// The Query
$query = new WP_Query( $args );