I need to show a block for terms of a certain vocabulery. Drupal.org has this snippit for Drupal 6, but I cant find anything for Drupal 7.


Im looking at PHP in the block visibility settings as Im assuming its the best way, but id be happy with any other solution. Thanks


2 Answers 2


If you want to do this on the term pages you should be able to use this code from Drupal.org. Just replace the function call taxonomy_get_term with taxonomy_term_load.

The code is copied below:

  $desired_vocab = 1; // put here the vocabulary ID you're interested in

  if ( ((arg(0) == 'taxonomy')
    && (arg(1) == 'term')
    && is_numeric(arg(2))
    && ($term = taxonomy_term_load(arg(2)))
    && ($term->vid == $desired_vocab )) ) {
      return TRUE;

It's always better to avoid placing PHP in the database. I suggest you use the module Block Visibility by Term.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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