Assuming you want to delete by date, here is a basic concept. You’d need to figure out when you want this to run, otherwise, as I commented above, you’ll end up with only 1 post if it runs repeatedly.
Edit: Including parameter for a bit of safety
<?php
function doomsday_device($herd_thinning) {
if(empty($herd_thinning)) {
return;
}
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1
);
$loop = new WP_Query($args);
if($herd_thinning > $loop->post_count) {
return;
}
$kill_num = $loop->post_count / 2;
$i = 0;
while($loop->have_posts()) : $loop->the_post();
if($i >= $kill_num) {
break;
}
wp_trash_post($post->ID);
$i++
endwhile;
}
?>
Must stress that this is a very dangerous function. If you attempt it, please back up your database. And you’ll need to pass an integer to it that represents a total post count size that is too large for your liking, which will then allow the thinning.