Drupal - How to mass-unpublish nodes?

If you want unpublish all nodes, quick and dirty method is simple sql query UPDATE node SET status = 0; Then clear cache and its done. But if you use Views, they could still show unpublish content depends on settings.


If you do not want to do this through SQL, the Content Management Filter module allows you to filter your content greatly, and determine how many rows are displayed on a page (therefore, allowing you to do bulk operations with ease).

Another module worth checking is Views Bulk Operations (aka VBO). It'll make it easy to create a view entirely geared towards bulk updates.


I am going to throw out one more option.

Write a test script that

  1. Bootstraps.
  2. Queries the database to find the nids you want to unpublish, then loops over the nids
  3. $node = node_load($nid);
  4. $node->status = 0;
  5. node_save($node);

Depending on your version of Drupal, you may be able to optimize this with node_load_multiple(). Just be sure you have enough memory available and you adjust execution time, if necessary.

Doing it this way should take care of any housekeeping that the node_save() fires.

Tags:

Nodes