Delete all nodes by content type


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $type = 'YOUR CONTENT TYPE';
  3. $aquery = db_query('SELECT n.nid FROM {node} n WHERE n.type = "%s"', $type);
  4. if(user_access('administer nodes')) {
  5. $count = 0;
  6. while ($n = db_fetch_object($aquery)) {
  7. node_delete($n->nid);
  8. echo $n->nid . 'deleted.';
  9. $count++;
  10. }
  11. echo $count . 'nodes deleted';
  12. }
  13. else {
  14. echo "No " . $type . " nodes found or you do not have permission to modify nodes.";
  15. }
  16. ?>

URL: http://drupal.org/node/92861

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.