"; $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); if ( $_POST['dry_run'] != '1' ) { if ( update_post_meta( get_the_ID(), $replace_field, trim( $value ) ) === true ) { echo "
";
print_r( $args );
echo sprintf( "ID: %d
%s: %s
Title: %s
%s: %s", get_the_ID(), $search_field, $key, get_the_title(), $replace_field, $value );
$success++;
}
}
}
} else {
$not_found[]= $key;
echo "No results
";
}
}
echo "Updated $success custom fields OK.
";
echo "Errors
";
if ( count( $not_found) > 0 ) {
echo "Posts with the custom field $search_field with these values could not be found:
\nNone.
"; } } ?>