26 March 2018

Delete all taxonomy terms from all vocabularies in Drupal 7. This is ran by Drush, but you can run it from wherever Drupal is initialised.

Source code viewer
  1. # All terms in a certain vocabulary.
  2. drush -v eval 'foreach(taxonomy_get_tree(VID) as $term) { taxonomy_term_delete($term->tid);}'
  3.  
  4. # All terms in all vocabularies.
  5. drush -v eval '$vocabularies = taxonomy_get_vocabularies(); foreach($vocabularies as $vocabulary) { foreach(taxonomy_get_tree($vocabulary->vid) as $term) { taxonomy_term_delete($term->tid);}}'
Programming Language: Bash