Skip to content

Instantly share code, notes, and snippets.

@andyg5000
Last active December 20, 2015 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyg5000/6188878 to your computer and use it in GitHub Desktop.
Save andyg5000/6188878 to your computer and use it in GitHub Desktop.
Delete all nodes of a particular bundle (content type). [Without Views Bulk Operations]
<?php
// Instantiate a new Entity Field Query
$efq = new EntityFieldQuery();
// Add a condition of entity_type = node and bundle = article.
$results = $efq->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'article')
->execute();
if (!empty($results['node'])) {
// Loop through each of the results and execute node_delete().
foreach($results['node'] as $node) {
node_delete($node->nid);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment