get all posts with certain meta data
I think you can do a left join : left join $wpdb->postmeta my_field_meta on (p.ID = my_field_meta.post_id and my_field_meta.meta_key = ‘subscribe’) Where “subscribe” it’s the name of your custom field. So your code could be: $dayswithposts = $wpdb->get_results(“SELECT DISTINCT DAYOFMONTH(p.post_date) FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta my_field_meta on (p.ID = my_field_meta.post_id and my_field_meta.meta_key = … Read more