0

I've been trying to figure our how to get a term ID of a taxonomy term I created, and I found a little bit of php that looks like it should work. However I have no idea where to put it to get a response.

I'm working on a D6 site that needed updating and already found this script

$term = taxonomy_get_term($tid);
$name = $term->name;

Any pointers?

  • A little additional info. I'm just trying to create a view and need the taxonomy id of a term to add as a filter. – Josh G. Apr 30 '14 at 19:55
  • Are you creating a view with Views or are you using hook_node_view()? – Marcel Apr 30 '14 at 22:01
  • I'm creating a view with views, and I need to pull in multiple terms from different taxonomies, so I figured using the taxonomy ID would work best. – Josh G. Apr 30 '14 at 22:15
  • If you load nodes in the view all taxonomy terms are allready associated with it. so there is no problem? – Marcel Apr 30 '14 at 22:21
  • Haha well thats what I'm trying to do. Add the nodes by using the TID. ...the below answer worked for me though. – Josh G. Apr 30 '14 at 22:25
1

That code won't work. The first line is using the $tid to load the term, obviously that won't work if you don't know the Term ID in the first place.

You don't need to use any PHP to get a taxonomy terms ID. Just goto the edit page of that term and look at the url. It will be /taxonomy/term/TID/edit

  • Ahh I didn't realize this was in there! Thanks for the help! – Josh G. Apr 30 '14 at 22:24

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.