List latest post for each tag with a category

I have a page where the latest posts are displayed from within a specific category.

array( 
    'posts_per_page' = -1,
    'post_status'=publish,
    'post_type'=post,
    'orderby'=post_date,
    'order'='DESC',
    'cat'=5
)

Within this I would like to only show the latest post for each tag. I don't know if this is possible but I'm hoping I'm wrong.

Topic array tags Wordpress

Category Web


I think I've cracked it. So now the latest post for each tag type is now displayed. A bit beyond my coding level but its working.

<?php $args = array(
'type' => 'post',
'orderby' => 'post_date');
$tags = get_tags($args);
foreach($tags as $tag) { 
    $the_query = new WP_Query( 'tag='.$tag->slug );
    if ( $the_query->have_posts() ) {
        $the_query->the_post();
        $desired_posts[] = get_the_ID(); // all the post IDs stored here.
    } else {
    // no posts found
    }
    wp_reset_postdata();
}
$args1 = array(
    'post_type' => 'post',
    'orderby' => 'date',
    'post__in' => $desired_posts,
    'posts_per_page' => -1
); 
$the_query = new WP_Query( $args1 );
    if ( $the_query->have_posts() ) {
        while ( $the_query->have_posts() ) {
        $the_query->the_post(); ?>
            
      <div class="">MY HTML STUFF HERE</div>                    
                        
       <? } } else {
    // no posts found
    }; ?>

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.