Last active
December 20, 2015 20:09
-
-
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]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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