get term archive url / link

Use get_term_link

e.g. to print out a list of actors terms linking to the archives:

$terms = get_terms('actors');
echo '<ul>';
foreach ($terms as $term) {
    echo '<li><a href="'.get_term_link($term).'">'.$term->name.'</a></li>';
}
echo '</ul>';

However!

If what you really mean is the equivilant of the custom post type archive, that lists all the posts of that type, but for taxonomy terms, e.g. a page that acts as an archive listing the various taxonomy terms available, then you’re out of luck. There are no taxonomy archives in WordPress for terms, only posts assigned to a given term.

To produce a page listing the taxonomy terms you can use code similar to the above. Then put it in a page template and use that page as your taxonomy term archive.

The reason why is that the problem lies in the post loop, almost every single page template is intended to have one, and if you look at the template heirarchy, if the necessary templates aren’t found, it all goes back to index.php, and index.php has a post loop that displays posts, not a term loop. This and the many different ways and ideas of how terms should be listed means there is no consensus. What about date archives? Should there be an archive listing months and years? Timelines? Panels tiles clouds etc

Leave a Comment