$pages = get_posts(array(
'post_type' => 'page',
'numberposts' => -1,
'tax_query' => array(
array(
'taxonomy' => 'taxonomy-name',
'field' => 'id',
'terms' => array(1,2,3) // Where term_id of Term 1 is "1".
'include_children' => false
)
)
));
Попробуйте с этим
Это может быть так же
$terms = get_terms('taxonomy-name');
foreach($terms as $term) {
$posts = get_posts(array(
'tax_query' => array(
array(
'taxonomy' => 'taxonomy-name',
'field' => 'slug',
'terms' => $term->slug
)
),
'numberposts' => -1
));
foreach($posts as $post) {
// do what you want here
}
}