Customising WordPress Using Templates

In order to customize a WordPress theme, you may need to decide which template file needs editing in order to provide a conditional display. Say you want to have a link to you favorite book retailers which only appears on your books page http://techcosupport.com/press/category/books/, then you may need to build a custom template for that page.

WordPress uses the Query String, the information contained within each link on your web site, to decide which template or set of templates will be used to display the page. If your visitor clicks on a link to a category page like http://techcosupport.com/press/category/books/, then WordPress looks for a template file that matches the category’s ID in the directory for the current theme. If it is missing, WordPress next looks for a generic category template file, category.php. Failing that archive.php and if that is missing the main theme template file, index.php.

In order to find out the category ID number go to Manage Categories and hover your mouse over your target category and the ID will show up in the link. Alternatively if you are editing a category, the ID will be displayed at the end of the url.

You then create your custom page with the name category-2.php in the case of http://techcosupport.com/press/category/books/. After that, when you display Books the custom page will display. Easy!

For more detail on the use of templates see Codex WordPress Template Hierarchy