Skip to content

Instantly share code, notes, and snippets.

@micjamking
Created October 24, 2017 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save micjamking/000f949da7bea0d308450301c1aa88d8 to your computer and use it in GitHub Desktop.
Save micjamking/000f949da7bea0d308450301c1aa88d8 to your computer and use it in GitHub Desktop.
Bulk update ALL WordPress post statuses in SQL
# Change post_type value if targeting 'page' or a custom post type
# Change ALL posts status from 'publish' to 'draft'
UPDATE wp_posts SET post_status = 'publish' WHERE (post_type = 'post' and post_status = 'draft')
@shtefcs
Copy link

shtefcs commented Jul 18, 2018

Hey Mike, if I wanted to update the posts date, to latest or some random, what would be SQL command for that ?

Peace,

@shtefcs
Copy link

shtefcs commented Jul 22, 2018

UPDATE wp_posts SET post_date="2018-07-21 01:16:30" WHERE post_status="publish" AND post_type="post"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment