Skip to content

Instantly share code, notes, and snippets.

@vineettalwar
Last active April 16, 2024 10:56
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 vineettalwar/e23dae83cc2ea45a1f37d54606e94952 to your computer and use it in GitHub Desktop.
Save vineettalwar/e23dae83cc2ea45a1f37d54606e94952 to your computer and use it in GitHub Desktop.
WP CLI Useful commands
//Delete all blog comments which are marked as pending
wp comment delete $(wp comment list --status=hold --format=ids) --force
// Get comments from specific post ID:
wp comment list --post_id={POST_ID} --fields=ID,comment_author
// Get comments form specifc post from specific comment status
wp comment list --post_id={POST_ID} --status=hold --fields=ID,comment_author
// Mark as spam to comments on a specific post with status hold
wp comment spam $(wp comment list --post_id={POST_ID} --status=hold --format=ids)
// Delete comments on a specific post with status hold
wp comment delete $(wp comment list --post_id={POST_ID} --status=hold --format=ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment