I would have preferred to put this as a comment, but space does not allow for it so sorry about that. It might help you rather than being an answer. I am using ‘product’, but it could just as easy be ‘post’.
function update_all()
{
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
);
$products_array = get_posts($args);
if (!empty($products_array))
{
foreach ($products_array as $product)
{
echo "product : " . $product->ID;
//Update whatever here, eg wp_update_post($product->id,$error);
}
}
echo "</pre>";
}
As you have the product id for each product in a loop, you can get any meta or custom values for that product, and update them. I used this to bulk update prices for example. Obviously you would only want to run this from time to time, so I keep it remarked in the code. You could of course run it as a cron. I am a bit unclear on what you are trying to update. Looks to me like it’s simply the publish date, which you could do in a loop.
I fail to see why wp_update_post in this loops wouldn’t do it. Perhaps you need to enable displaying the errors when it runs.