Delete multiple nodes in Drupal
Less than 1 minute
Delete multiple nodes in Drupal
$content_type = 'content_type_name';
$nids = \Drupal::entityQuery('node')
->condition('type', $content_type)
->execute();
use \Drupal\node\Entity\Node;
$nodes = Node::loadMultiple($nids);
foreach($nodes as $node) {
$node->delete();
}
$storage_handler = \Drupal::entityTypeManager()->getStorage('node');
$entities = $storage_handler->loadMultiple($ids);
$storage_handler->delete($entities);