How do I get a node, or a taxonomy term URL knowing the node ID or the taxonomy term ID?
-
16-10-2019 - |
Question
I need to render the full URL from a taxonomy term ID.
Solution
The generic way is this:
$uri = entity_uri($entity_type, $entity);
$url = $uri['path'];
So for a node, $entity_type
would be 'node', and $entity
would be the fully loaded node object.
Taxonomy terms are also entities in D7, so the syntax would be similar.
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange