Skip to content

Instantly share code, notes, and snippets.

@thinkclay
Created February 7, 2014 03:49
Show Gist options
  • Save thinkclay/8857122 to your computer and use it in GitHub Desktop.
Save thinkclay/8857122 to your computer and use it in GitHub Desktop.
Navicat Function to update Wordpress Post dates
BEGIN
SET @ID = 1;
WHILE @ID < 100 DO
UPDATE wp_posts SET comment_count = (SELECT COUNT('ID') FROM wp_comments WHERE comment_post_ID = @ID) WHERE ID = @ID;
SET @ID = @ID + 1;
END WHILE;
UPDATE wp_posts SET post_date = (SELECT FROM_UNIXTIME(post_time));
UPDATE wp_posts SET post_date_gmt = (SELECT FROM_UNIXTIME(post_time));
UPDATE wp_comments SET comment_date = (SELECT FROM_UNIXTIME(comment_time));
UPDATE wp_comments SET comment_date_gmt = (SELECT FROM_UNIXTIME(comment_time));
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment