This should works.
$args = array(
'taxonomy' => 'your_taxonmy_name', // replace with your taxonomy name
);
$categories = get_categories( $args );
$ids = array();
// lets get all post IDs
foreach ( $categories as $category ) {
$args = array(
'cat' => $category->term_id,
'post_type' => 'homepage', // your post type
'posts_per_page' => '1',
'post__not_in' => $ids, // don't want to any duplication
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
$query->the_post();
$ids[] = get_the_ID();
}
}
wp_reset_postdata();
$args = array(
'post__in' => $ids,
);
$query = new WP_Query( $args );
// your loop for echoing
if ( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
// do what you want to
}
}
wp_reset_postdata();