get_posts by taxonomy code example
Example 1: wordpress get taxonomy of a post
<?php $term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
Example 2: get posts from selected taxonomy
$posts_array = get_posts(
array(
'posts_per_page' => -1,
'post_type' => 'fabric_building',
'tax_query' => array(
array(
'taxonomy' => 'fabric_building_types',
'field' => 'term_id',
'terms' => $cat->term_id,
)
)
)
);