I can easily link to my archives page by creating a link: <a href="http://server.com/wordpress/archives.php">Archives</a>
. As I was editing my WP template, I noticed that there are a number of functions that WP uses to link to other pages. For example get_the_category_list
returns a list of links. If I want to make my template more general, it would be nice not to hardcode the URL of my archives page and to use a WP function instead.
In general, how should template designers create links to WP generated pages?
This link WordPress Codex: Linking… provides detailed information on how to link different types of content. One nice feature that solves the above problem is to use a link of the form
/wordpress/archives.php
. This will transfer nicely (in most cases) to any particular server deployment.Further, looking in
wp-includes/link-template.php
gives you more insight to what kinds of tools are already available for creating links. Particularly helpful ishome_url()
which allows you to try to be as server agnostic as possible.