On the top of the Archives, I have an additional Navigation, it shall help the user sorting the posts:
You can sort by tag, category or month. An Example:
I am browsing the archive of category 'apples', a page of this archive shows in my case seven posts. If some or all of those posts are assigned to another category besides apples, lets say 'peaches' that category shall appear on top, as navigation point.
Okay: We browse the cat. of apples, see the list on top which shows additional catgeories, the posts in apples are assigned to, you click pears and come to apage, that shows all posts that are assigned to apples and pears.
The same with the tags.
Currently, I am trying to call all the categories of all posts in a catgory (with tags it should be the same) with this function:
$categories = get_the_category($post->ID);
$catid = get_cat_id(''.single_cat_title("", false).'');
But now I realized, that thsi function shows only the categories for the first post in archive, but not all.
I hope my description helped you, to understand, what I try to get.