(I know I wrote yesterday I’ll take a blogging break but I got an email on this topic, so I think it’s better to write a post about it).

Custom page templates

In WordPreciousss 3.0 you can have global custom page templates, but to make use of them there’s two things you need to do.

  1. Custom page templates need to have the file name page-name.php
  2. To use the custom page template on a page you need to use the custom fields:
    key = page_template, value = name (name is the same a page-name.php)

In the default package of WordPreciousss you’ll find three custom page templates in the directory /templates/myown/:

  • page-links.php - for a link page
  • page-archives.php - for a archive page
  • page-search.php - for a quick search page included with tagcloud and search form

If you copy these to /templates/precious they will apply to all themes on your site. The custom page templates can be overwritten in a theme by creating a file with the same name. And you may create custom page templates that applies to only one theme if you like.

But as you see, there’s no need to add the header /*Template Name:*/ in custom page templates if you use WordPreciousss.

If you’re a theme author and want to add some support for WordPreciousss in your theme, you can give your custom page templates the filename page-name.php instead of just name.php

WordPreciousss also have a conditional tag called is_precious_page_template('name') to go with the page templates. Again the variable “name” is the same as page-name.php

Example usage for page-links.php:

<?php if(is_precious_page_template('links')) { ?>
<p>Here's a lot of cool links I've found on the web!</p>
<?php } ?>

Custom single templates

Custom single templates is a speciality of WordPreciousss and works the same way as the custom page templates.

The difference is that a custom single template need to be named single-name.php, and when loading it using custom fields the key = single_template

The custom single templates also have a conditional tag: is_precious_single_template('name'), which works the same way as is_precious_page_template('name')