I'am using hook_taxonomy_term_presave to redirect file urls to another link.

In order to see the changes I need to go to : Mysite/taxonomy/term/10/edit and save the page.

I need to do this operation for all taxonmy terms of my website, is there a way to do this automatically whithout editing every page and save it ?


  • Do you have drush installed? – Елин Й. Jan 6 '15 at 17:46
  • @ЕлинЙ. Yes I have drush installed. – Willypowa Jan 6 '15 at 17:50

The best I know from your question is to use the Views Global Filter module.

Using this module you can save you taxonomy term into cookie and get any where in the page and can also redirect and filter the results.


I used this to get all my taxonomy terms :

function Mymodule_update_7100() {
 $terms = array();
 $v = taxonomy_vocabulary_machine_name_load('vocab_name');
 $query = new EntityFieldQuery();
 $result = $query
  ->entityCondition('entity_type', 'taxonomy_term')
  ->propertyCondition('vid', $v->vid)

if (!empty($result['taxonomy_term'])) {
  $terms = entity_load('taxonomy_term', array_keys($result['taxonomy_term']));
    foreach($terms as $term){

I hope this will help someone else. Thank's again @Елин Й.


You can do this in your modules .install file, using hook_update_N. The script you need:

 * Updates all terms in 'vocabulary_name' vocabulary.
 * Change the update number accordingly if you have previous updates already.
function YOURMODULE_update_7100 {
  $vocabulary = taxonomy_vocabulary_machine_name_load('vocabulary_name');
  $terms = taxonomy_get_tree($vocabulary->vid, 0, NULL, TRUE);
  foreach ($terms as $term) {

After that simply run your update script by calling update.php or using drush:

drush updatedb

Method 2

If you don't want to use an update script, you can do it using drush php-eval, as well. This is a one-line version of the above script:

drush php-eval '$v = taxonomy_vocabulary_machine_name_load("vocabulary_name"); $ts = taxonomy_get_tree($v->vid, 0, NULL, TRUE); foreach ($ts as $t) {taxonomy_term_save($t);}'

  • Glad that it helped. I've noticed that I had a typo in the update script, so it wouldn't work as it was. – Елин Й. Jan 7 '15 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.