Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created February 3, 2014 13:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tommcfarlin/1c56c3f5c993db5125d9 to your computer and use it in GitHub Desktop.
Save tommcfarlin/1c56c3f5c993db5125d9 to your computer and use it in GitHub Desktop.
[WordPress] A strategy for how to retrieve custom post types tagged with multiple taxonomies.
<?php
$args = array(
'post_type' => 'acme_post_type',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'acme_labels'
'field' => 'term_id',
'terms' => 100
),
array(
'taxonomy' => 'acme_labels',
'field' => 'term_id',
'terms' => 200
)
)
);
$posts = get_posts( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment