Last active
July 9, 2021 15:07
-
-
Save garraflavatra/6877a73443660cd39287a826aeb3d1cf to your computer and use it in GitHub Desktop.
How to query WordPress posts with a custom taxonomy term.
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
<?php | |
$posts = get_posts( | |
array( | |
'numberposts' => 20, | |
'post_type' => 'custom_post_type', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'custom_taxonomy', | |
'field' => 'slug', | |
'terms' => array( 'termslug1', 'termslug2' ) | |
) | |
) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment