I have pathauto installed on my D7 setup along with all my taxonomy terms configured.

How do I then call the alias using PHP for custom code?

EDIT: just to clear things up - I want to output the alias URL that has been created and assigned to each specific node. For example:

Terms - Country - City

For node #1 an alias is created as {site}/[country]/[city]

I would like to output the alias that has been created for the node so I can visit for example {site]/england/london instead of {site}/node/1

1 Answer 1


If you mean the alias for the taxonomy term you can use url() (if you just want the URL), or l() if you want a link:

$url = url('taxonomy/term/' . $term->tid);

$link = l('Link text', 'taxonomy/term/' . $term->tid);

Both of those will give you the current path alias for the term page

  • 2
    also $path = drupal_get_path_alias('taxonomy/term/' . $term->tid); if all you want is the bare path.
    – Jimajamma
    Apr 9, 2013 at 17:42

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.