Display blocks on nodes tagged with a taxonomy term in Drupal 7 6/19/13
In Drupal 7 it is pretty easy to display or not display blocks on specific nodes. It gets more tricky if you want to display blocks according to other criteria, like nodes tagged with a taxonomy term. In that case you can use this bit of PHP in your block visibility settings:
This code will also display the block on taxonomy term list pages. Just be sure to change the $term_id_to_trigger_show_block
to the taxonomy term ID you want to match and the $taxonomy_to_search
to the machine name of the taxonomy you want to search1. Also, when you put this in your block visibility settings, make sure you have the radio button set to “Pages on which this PHP code returns TRUE”:
-
You can find this information in the admin under Structure / Taxonomy. ↩