As you assure me that the post title is an accurate indicator of the “duplicate” status of the post, a little bit of SQL and wp_delete_post()
will do it:
$sql = "SELECT ID
FROM {$wpdb->posts}
WHERE post_title REGEXP '^.*-[[:digit:]]*$'
AND post_type="page"";
$del = $wpdb->get_col($sql);
foreach ($del as $d) {
wp_delete_post($d);
}
As written, your duplicates will end up in the “trash”, unless that is disabled. You can use…
wp_delete_post($d,true);
… to force deletion.
Based on a comment below:
I created pages depending on locations and I’ve just realised that I
have pages such as Berwick upon Tweed and Berwick-Upon-Tweed I’d
Ideally like to delete the pages with the – in the title…
I can’t help but think that that is a phenomenally dangerous thing to do, but the SQL is simple:
$sql = "SELECT ID
FROM {$wpdb->posts}
WHERE post_title LIKE '%-%'
AND post_type="page"";