From a page based on a url of taxonomy/term/##, how do I properly get the tid (the numeric value in the URL) without using args()? Is using args() a decent way of doing this?

  • 2
    What is the end goal? In what context do you need the tid for? Commented Jun 27, 2014 at 6:57
  • To sum up, this is one of those questions that, after helpful feedback that made me questioned why and what, I decided to approach this from an entirely different way.
    – Rick
    Commented Jul 2, 2014 at 17:04

1 Answer 1


From where this page is coming, from core taxonomy or views?.

By default the taxonomy module provide the taxonomy/term/## callback and views module also provide a default view with the path taxonomy/term/##.

If you haven't enabled the Taxonomy term view then this page will be the default taxonomy core page, in that case you can use menu_get_object('taxonomy_term', 2) to get the loaded term.

For arg(), the document says

Avoid use of this function where possible, as resulting code is hard to read. In menu callback functions, attempt to use named arguments. See the explanation in menu.inc for how to construct callbacks that take arguments. When attempting to use this function to load an element from the current path, e.g. loading the node on a node page, use menu_get_object() instead.

  • On menu_get_object() what does the second parameter ("2") express?
    – Rick
    Commented Jul 2, 2014 at 17:05
  • The position of the object in the path, like taxonomy(0)/term(1)/##(2)
    – msmani
    Commented Jul 2, 2014 at 17:08

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.