File: /var/www/school/wp-content/themes/school/fix-acf.php
<?php
require_once( dirname(__FILE__) . '/../../../../wp-load.php' );
$field_name = 'online-option'; // change this to your ACF field name
$post_type = 'product';
$posts = get_posts([
'post_type' => $post_type,
'posts_per_page' => -1,
'post_status' => 'any',
]);
foreach ($posts as $post) {
$value = get_field($field_name, $post->ID, false);
if (is_array($value)) {
$cleaned = array_map(function($v) {
// Remove "value:" if present
if (strpos($v, ':') !== false) {
return trim(explode(':', $v, 2)[1]);
}
return trim($v);
}, $value);
update_field($field_name, $cleaned, $post->ID);
echo "✅ Cleaned post ID {$post->ID}<br>";
}
}
echo "<strong>Done.</strong>";