Here we have simple way to 'delete content programmatically'. We can use this code in our "custom module/plugin" or "hook_entity_predelete" or in "hook_entity_delete". Just use that simple code..
Syntax:
$result = \Drupal::entityQuery("node")
->condition('type', 'resources'); // here change the content type of your
$nids = $result->execute();
if (!empty($nids)) {
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);
$nodes->delete();
}
#Extra notes: here we can add more conditions in 'entityQuery' as per our requirement.
Note: How to delete content node programmatically in drupal 8?
Syntax:
$result = \Drupal::entityQuery("node")
->condition('type', 'resources'); // here change the content type of your
$nids = $result->execute();
if (!empty($nids)) {
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);
$nodes->delete();
}
#Extra notes: here we can add more conditions in 'entityQuery' as per our requirement.
Note: How to delete content node programmatically in drupal 8?