6

Taxonomy term path:

http://api.drupal.org/api/function/taxonomy_term_path

Returns the unaliased path. I used pathauto to give the term alias, how can I return the aliased version?

Thanks.

Jourkey
  • 33,710
  • 23
  • 62
  • 78
  • Check my answer here [on how to use taxonomy entity index][1] [1]: http://stackoverflow.com/a/12640937/438977 – Bery Sep 28 '12 at 13:27

2 Answers2

15

Use drupal_get_path_alias()

$path_alias = drupal_get_path_alias(taxonomy_term_path($term) );
Owen
  • 82,995
  • 21
  • 120
  • 115
  • 11
    `taxonomy_term_path()` is for Drupal 6 only. For Drupal 7 use: `taxonomy_term_uri()` however it wants a term object, so you may need to use it like this: `drupal_get_path_alias(taxonomy_term_uri($term))` where $term needs to be the term object or you can fake it with `$term = (object) array('tid' => $tid)` (provided you know the tid!) – marblegravy Aug 03 '12 at 05:08
1

you may want to explore the url() function as well. I use it all of the time with node ids.

$node_href = url('node/'.$nid);

although you probably want something like:

$term_href = url('taxonomy/term/' . $tid);
electblake
  • 2,027
  • 18
  • 25