Created
April 5, 2019 17:43
-
-
Save imagebox/24ccb9f4610b72aaa66d5a2faff745bf to your computer and use it in GitHub Desktop.
[WordPress | Query Posts by Taxonomy Term] WordPress | Query for posts by taxonomy term. #WordPress #query #taxonomy #term
This file contains hidden or 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
<?php | |
$the_query = new WP_Query( array( | |
'post_type' => 'post_type_name', | |
'tax_query' => array( | |
array ( | |
'taxonomy' => 'taxonomy_name', | |
'field' => 'slug', | |
'terms' => 'taxonomy_term', | |
) | |
), | |
) ); | |
while ( $the_query->have_posts() ) : | |
$the_query->the_post(); | |
// Show Posts | |
endwhile; | |
wp_reset_postdata(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment