Last active
April 14, 2017 05:22
-
-
Save khromov/ef70650f63cf9bc8f1e3 to your computer and use it in GitHub Desktop.
wordpress-taxonomy-query-acf-taxonomy-field-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$post_id = 1; //Post ID | |
$post_taxonomies = get_field('assigned-taxonomies', $post_id); | |
$args = array( | |
'post_type' => 'post', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'your-taxonomy', | |
'field' => 'term_id', | |
'terms' => $post_taxonomies | |
), | |
), | |
); | |
$query = new WP_Query( $args ); | |
//Print result | |
print_r($query->posts); | |
//Print raw SQL | |
print_r($query->request); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment