Skip to content

Instantly share code, notes, and snippets.

@benjibee
Created March 15, 2023 15:50
Show Gist options
  • Save benjibee/521df7456baad6e93ef16bee9f1c81a8 to your computer and use it in GitHub Desktop.
Save benjibee/521df7456baad6e93ef16bee9f1c81a8 to your computer and use it in GitHub Desktop.
WordPress SQL Query: delete posts and post meta for posts older than N days
DELETE p, pm
FROM wp_posts p
INNER
JOIN wp_postmeta pm
ON pm.post_id = p.ID
WHERE p.post_type = 'page'
AND p.post_date < (NOW() - INTERVAL 120 DAY);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment