I was planning on creating a custom "Archives" template to create a detailed Archives page for my blog, including lists of posts by category, tag, date and author. Rather than use a static link though, is there a way within WordPress to get a link to a specific template file? I want the link to work regardless of the page's URL—is this possible?
closed as not a real question by toscho♦ Jul 13 '12 at 19:49
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.
Here's a function to print the URI of the first page using an "Archive" page template. It assumes the template is named template-archive.php (don't name it archive.php and hijack the Template Hierarchy!). You can either drop this in functions.php and call it in a template or you can just use the code within the function directly in a template file.
Depends on what its an archive of. Take a look at the Template Hierarchy...
As you can see there are many kinds of archives. Taxonomy, Category, Tag, Author, Date, and Posts. If no template of the specific type is found when on an 'archive' query, then WordPress defaults to a generic 'archive.php' template. If thats not found either, it will default to 'index.php'.
If you are trying to make a general archive page that shows several kinds of archives combined, you could theoretically do that anywhere in the hierarchy - the questions to answer then would be where and how you want that part of your site to show up - and what kind of data will be shown there (is it relative to the cat your on, or is it a central generic type of thing).
For example if you create a template called category.php, then any category request will show up using that template, unless you create a specific one for a particular category. So if you have category.php and category-myslug.php, then the 'myslug' category will show up with its special template, but all others will show up using the general category.php template.
To bring this all home, if your url is http://example.com/category/cat1, it can be made to use the same template as http://example.com/category/cat2 based on which templates do and done exist within your theme.
The same logic applies to tag templates, page templates, date-based archives, custom taxonomy templates, and custom post type templates. Additionally, if you want a single template to apply to ALL archives, just create an archive.php template and make sure you dont have one of the more specific ones in your theme.
Hope this helps.