0

There are a bunch of posts which carry a line of same text. I am trying to figure out a way that will delete the whole post if it finds this text in its exact form.

I haven't been successful in finding a plugin that will achieve this, but have found those that will delete duplicate posts which is not what I need.

1

If you're comfortable using phpMyAdmin, you can run this query:

DELETE FROM wp_posts WHERE post_content LIKE "%A line of same text that should be deleted%"

Replace with the text you're wanting to remove, but keep the "% %" symbols. The percent symbols mean to search for that string anywhere inside the post content - even if there's a bunch of other content before and after it.

If you have special characters in the line of text, you may need to escape them.

As with any query, make sure you have a current, working backup before you run this query. :)

  • Thanks for the response. I did a simulation on this and it returned 792 matches which is a little higher than I was expecting. Is there any way I can view the results of this 792? – JS7319 Jun 13 '17 at 21:41
  • Decided to run it. It actually got rid of the posts but also others too and dropped them all in the Trash which I had to restore. Not sure how that happened because I'm sure they didn't have the text in. The only special character was a hyphen. – JS7319 Jun 13 '17 at 21:56

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.