add this in functions.php, save then refresh once your site and then remove the snippet.
add_action('init', function () {
$paged = 1;
$per_page = 100;
do {
$query = new WP_Query([
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => $per_page,
'paged' => $paged,
'fields' => 'ids',
]);
foreach ($query->posts as $product_id) {
$title = get_the_title($product_id);
$new_title = ucwords(strtolower($title));
if ($title !== $new_title) {
wp_update_post([
'ID' => $product_id,
'post_title' => $new_title,
]);
}
}
$paged++;
} while ($query->found_posts > ($paged - 1) * $per_page);
});
Was this helpful?
YesNo