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?

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, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

Do I read your question correctly that you're thinking of a page template selected in the "Template" field?
– mrwwebMay 2 '12 at 17:25

2 Answers
2

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.

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.

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.

I wish the WordPress terminology were clearer, but if you reread the question, I believe this is about a custom "Archive" Page Template and not the archive.php or related template files.
– mrwwebMay 2 '12 at 17:53

He said template, and I am in fact talking about archives. There are many kinds of archives, thats what I was explaining. Theres no way to make a 'custom archive template' without it involving, well, a template.
– eddiemoyaMay 2 '12 at 18:17

You might be right about that, but thats not entirely clear from the post - however thats still a template - and if nothing else he should consider using something already made available in the hierarchy. With static pages/template like you mentioned theres really no simple built-in way to make something work dynamically for any archive query (like for any category, or for any post archive, etc), thats what the hierarchy allows you to do. Thats what I think he's asking for when he says it should work regardless of the URL. /category/cat and category/cat2 should both work.
– eddiemoyaMay 2 '12 at 18:59