Bulk Delete Nodes by Type in Drupal 8

For this to work you’ll need to execute it in PHP. A quick way to do so is to install the Devel module.

With Devel enabled, go to http://example.com/devel/php and execute the following:

$query = db_select('node', 'content_id');
$query->fields('content_id', array('nid'));
$query->condition('content_id.type', ['content_type_one','content_type_two'], 'IN');
$query->range(0, 1000);

$node_ids = $query->fetchCol(); 

entity_delete_multiple('node', $node_ids);

You can adjust the range above to more than 100, but the more you attempt to delete the slower your web server may become. Make sure you have at least 512MB memory dedicated in your php.ini file, along with extending the max_execution_time.

Leave a Reply

Your email address will not be published. Required fields are marked *