You can do this using the WP APIs like this:
$args = [
'post_type' => 'post',
'tax_query' => [
'relation' => 'AND',
[
'taxonomy' => 'your_taxonomy_name',
'field' => 'slug',
'terms' => array( 'arizona', 'speech-language-pathology' ),
]
],
];
$query = new WP_Query( $args );
Then you can use $query
as you would any standard post loop.
If you only want the IDs you can use the fields
option of WP_Query
, but keep in mind you won’t gain all the caching and performance benefits you might have gotten otherwise, especially if you’re going to pass the ID into get_post
$args = [
'post_type' => 'post',
'tax_query' => [
'relation' => 'AND',
[
'taxonomy' => 'your_taxonomy_name',
'field' => 'slug',
'terms' => array( 'arizona', 'speech-language-pathology' ),
]
],
'fields' => 'ids'
];
$query = new WP_Query( $args );
$posts = $query->get_posts(); // $posts is an array of post IDs