Remove all nodes for a content type

If you want to clean your Drupal installation and remove everything that belongs to a content type, it is better to use a Drupal query. You shouldn’t try to remove them directly from a custom SQL Query. Here is how you can use Drupal db_query function:

Another technique

 

2 Thoughts on “Remove all nodes for a content type

  1. I would like to remove all nodes of a specific content type and also all the comments on that node.

    There are over 20000 nodes of that content type and in total +900000 comments. Comments are also on other content types.

    Is it a good idea to run another foreach-loop in the other foreach loop to remove all comments?
    I guess it will be a very bad load for the server.

    Or are there other alternatives?

    Thanks,
    Stijn

    • Admin on October 27, 2013 at 15:18 said:

      Normally if you run a node_delete(), Drupal will remove everything that is linked to this node, even comments.

      Did you try with a test node containing one comment ?

Leave a Reply

Your email address will not be published.

Post Navigation