How to Delete All Content From Specific Content Types In Drupal
With just 2 Drush commands
Sometimes we need to delete content from a content type or multiple content types in Drupal. This is usually not a problem if there are only a few of them, or even 50 or 100. The problem comes when it has thousands of contents and it would take us hours to delete them. We could be tempted to delete them directly from the database, but that’s not a good idea, as there are many dependencies between tables and that could cause an issue.
There is a better way, and it is using devel generate module. With just 2 Drush commands we can easily delete them.
First, add the module devel. Go to https://www.drupal.org/project/devel, and run the composer require command that suits your project
Then, enable devel generate module:
drush en devel_generate -y
Run this command (replacing bundle with yours, i.e: article):
drush genc 0 --bundles=bundle --kill
Or this one if you want to delete multiple contents from different content types (replace article, page with your bundles):
drush genc 0 --kill --bundles="article, page"
And that’s it, now you have deleted all nodes for that bundle.
👉 Find out more about me here: https://sergioguardiola.net 🔥