The easiest way is by using custom MySQL query with WPDB
class.
global $wpdb;
$table = $wpdb->prefix . 'posts';
$sql = "SELECT DATE(post_date) AS date, COUNT(ID) AS count
FROM {$table} WHERE post_type="my_post_type" AND post_status="publish" GROUP BY DATE(post_date)";
$rows = $wpdb->get_results($sql);
Or if you want to prevent SQL injection, you can use prepared statement like this:
global $wpdb;
$sql = $wpdb->prepare(
"SELECT DATE(post_date) AS date, COUNT(ID) AS count
FROM %s WHERE post_type = %s AND post_status="publish" GROUP BY DATE(post_date)",
array(
$wpdb->prefix . 'posts',
'my_post_type'
)
);
$rows = $wpdb->get_results($sql);
Then you can iterate the $rows
to show the data.
foreach ($rows as $row) {
echo $row->date . ' -- ' . $row->count;
}