this code will display the post from all taxonomy in wordpress:
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '',
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'number' => '',
'taxonomy' => 'season',
'pad_counts' => false
);
$taxonomy = get_categories( $args );
foreach ( $taxonomy as $tax ) {
$posts_array = get_posts(
array(
'posts_per_page' => -1,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'season',
'field' => 'term_id',
'terms' => $tax->term_id,
)
)
)
);
print_r( $posts_array );
}
if you want to display specific post then pass below codes:
$posts_array = get_posts(
array(
'posts_per_page' => -1,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'season',
'field' => 'term_id',
'terms' => 2, // taxonomy id
)
)
)
);
print_r( $posts_array );