Skip to content

Instantly share code, notes, and snippets.

@DriftwoodJP
Created July 30, 2018 09:00
Show Gist options
  • Save DriftwoodJP/aa03773151163bcb4440fb69ee344862 to your computer and use it in GitHub Desktop.
Save DriftwoodJP/aa03773151163bcb4440fb69ee344862 to your computer and use it in GitHub Desktop.
To delete all terms, posts & comments in WordPress
#!/bin/bash
# Delete all categories.
wp term list category --field=term_id | xargs wp term delete category
# Delete all post tags.
wp term list post_tag --field=term_id | xargs wp term delete post_tag
# Delete all posts.
wp post delete --force $(wp post list --format=ids)
# Delete all pages.
wp post delete --force $(wp post list --post_type='page' --format=ids)
# Delete all comments.
wp comment delete --force $(wp comment list --format=ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment