If you want to delete all the fields, do it directly in the database, or in admin area. But if you'd like to keep one copy of each field, and only delete the duplicates, well, it's a bit more complicated.
You can delete directly from the database, using an intricate SQL statement like:
delete from wp_postmeta
where meta_id in (
select *
from (
select meta_id
from wp_postmeta a
where a.meta_key = 'podPressPostSpecific'
and meta_id not in (
select min(meta_id)
from wp_postmeta b
where b.post_id = a.post_id
and b.meta_key = 'podPressPostSpecific'
)
) as x
);
Don't forget to change name of the meta_key on both places if you want to delete duplicates for another custom field.
or you can use a php script for this. Example:
<?php
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
define( 'WP_DEBUG_DISPLAY', true );
ini_set( 'display_errors', true );
$allposts = get_posts('numberposts=-1&post_type=post&post_status=any');
$keys = array('podPressPostSpecific', 'aktt_tweeted', 'podPressMedia');
foreach ( $keys as $key ) {
foreach( $allposts as $postinfo) {
// Fetch array of custom field values
$postmeta = get_post_meta($postinfo->ID, $key);
if (!empty($postmeta) ) {
// Delete the custom field for this post (all occurrences)
delete_post_meta($postinfo->ID, $key);
// Insert one and only one custom field
update_post_meta($postinfo->ID, $key, $postmeta[0]);
}
}
}
?>