I have custom taxonomy term pages which I'm using to override forum pages and I want to emulate advanced forum node/add/forum/tid button so I have to get tid but don't know how, I can only find examples on how to print tid of the current node.


You can use below code to get Taxonomy id by Taxonomy Name

 $taxonomy_term = taxonomy_get_term_by_name('Taxonomy Term Name');
 $tid = $taxonomy_term>tid;
  • No it's not working at all, I tried this but it didn't work either <?php print $term->tid; ?>"> – drupaluser Jun 3 '15 at 18:27

You can use taxonomy_get_term_by_name and use arg(3) (those are the URL args find out more about those here in the docs) or something similar to pull the name. That function should return an array of match term objects. There should be more information on the taxonomy.module docs that could help as well, you can find them here: https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/6

I have experience in D6 but not as much as D7 but something like that should work or a custom query but I'd advise against those since there is already a function for it in the API.

  • I'm using drupal 6 I need to print it just the number – drupaluser Jun 8 '15 at 2:15
  • Is the tid part of the URL? – burnsjeremy Jun 8 '15 at 2:17
  • yes I want it to be a link – drupaluser Jun 8 '15 at 21:25

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.