Delete all terms in a vocabulary

Public

Takes in a (int) Vocabulary ID, and deletes all of its associated terms.

Get raw version
php
  1. /**
  2.  * Deletes all terms associated with a vocabulary.
  3.  *
  4.  * @param int $vid
  5.  * The VID of the vocabulary whose terms we are deleting.
  6.  */
  7. function delete_vocab_terms($vid) {
  8. $terms = taxonomy_get_tree((int) $vid);
  9. foreach ($terms as $t) {
  10. taxonomy_term_delete($t->tid);
  11. }
  12. }