Skip to content

Add an --all flag to wp comment delete #538

Description

@baizmandesign

Feature Request

Describe your use case and the problem you are facing

A website under my purview had hundreds of thousands of spam comments. It would be nice to be able to remove them in one fell swoop without having to resort to database queries (truncate wp_comments; truncate wp_commentmeta;).

Describe the solution you'd like

I'd like to add a flag to the wp comment delete subcommand:

wp comment delete --all

This may have a confirmation prompt along the lines of "Are you sure you want to delete XXXXX comments? (Y/n)" There might also be a "--yes" option for non-interactive use:

wp comment delete --all --yes

The addition of the "--all" flag would mirror similar-ish flags for the wp plugin delete --all and wp theme delete --all commands.

I'm aware that the wp site empty command also removes all comments, but this is a little bit different.

I'd be happy to take a stab at adding this modification, if approved.

Activity

  1. transferred this issue fromwp-cli/ideason Jul 14, 2025
  2. swissspidy commented on Jul 14, 2025

    @swissspidy
    Member

    The documented way for this is:

    # Trash all spam comments.
    $ wp comment delete $(wp comment list --status=spam --format=ids)
    Success: Trashed comment 264.
    Success: Trashed comment 262.

    But for hundreds of thousands of comments that doesn't really scale I suppose.

  3. baizmandesign commented on Jul 14, 2025

    @baizmandesign
    Author

    @swissspidy Thanks for your response. To be clear, the request isn't just for deleting spam comments, it's for deleting all comments (which is what happens with wp site empty). It's almost a subset of that command, but I don't think it belongs there.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions