How to get total posts count for each date?

Instead of the second loop, do the following:

  1. Count the posts per date

  2. Display them as you will

    // Count the posts per date
    $count = [];
    
    foreach ( $posts as $post ) {
    
        $date = get_the_date( 'Y-n-j', $post );
    
        $count[ $date ] =  ! isset( $count[ $date ] ) ? 1 : $count[ $date ] + 1;
    
    }
    

techhipbettruvabetnorabahisbahis forumutaraftarium24edusedueduseduseduedueduedueduedu