Skip to content

Instantly share code, notes, and snippets.

@tivnet
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tivnet/6e5ecd155d4bac275aff to your computer and use it in GitHub Desktop.
Save tivnet/6e5ecd155d4bac275aff to your computer and use it in GitHub Desktop.
WooCommerce: SQL to fix sorting by date
--
-- 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