Last active
August 29, 2015 14:05
-
-
Save tivnet/6e5ecd155d4bac275aff to your computer and use it in GitHub Desktop.
WooCommerce: SQL to fix sorting by date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- When the product "post date" is incorrect | |
-- (for example, as a result of batch import-export) | |
-- this SQL will fake the date using the post_ID | |
-- | |
-- @author Gregory Karpinsky, http://www.tiv.net/ | |
-- @version 14.08.19 | |
-- | |
UPDATE wp_posts | |
SET `post_date` = CURDATE( ) + INTERVAL ID SECOND | |
WHERE `post_type` = 'product'; | |
-- Assuming that WP timezone is UTC | |
UPDATE wp_posts | |
SET `post_date_gmt` = `post_date` | |
WHERE `post_type` = 'product'; | |
-- EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment