I have about 2000 titles. How can I automatically delete posts with these titles?

For example

My list


You probably want to do something like that from the command line. Or in the database itself. Automatically delete might not be possible unless you can figure out how to run this as a cron job. Best practice would be to not publish them in the first place.

You can set the screen option in Posts to show 200-500 results and select all and delete also. Ten times or so is a lot easier than learning the command line or SQL. Less risk of crashing or breaking other stuff.

  • Thanks but titles are not listed in order. I mean, if I do it the way you say, I have to choose one by one. I'm looking for a way to delete posts according to the list I have.
    – batuhan
    May 4 at 18:46

Like keepkalm said I'd find the list of post IDs from the database:

select id, post_title FROM wp_posts
where post_title like '%Pharmaton%'
or post_title like '%Winston Blu%'
or post_title like '%Kefir%'
or post_title like '%Tetradox%'
or post_title like '%Passport Sco%';

and then use the list of IDs with wp-cli's wp post delete which accepts a space-separated list of post IDs:

wp post delete 1 2 3 4

(You could also use wp post list to get all titles and IDs in the system, and grep to filter the list down to the posts you want, awk or similar to extract the list of IDs and then pass that all to wp post delete in one go - but this feels safer to do as a semi-manual process since you're deleting things.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.