New Template Types

Tidy Templates offers 2 new template types. They are actually based on existing templates, but are now more robust and usable.

Template specific pagination

Did you know that wordpress has templates for paged feeds? After page 1 of an archive feed, WordPress will look for paged.php to use. But wordpress applies the paged.php template to every type of feed.  That means your posts, search results, custom post types, taxonomies, terms ect, will all share the same template.

Tidy Templates provides feed specific paged support, so every feed can have it’s own paged template. Furthermore, you can specify templates for specific page numbers, and to take it further, this plugin will use the highest number paged template found if the current page isn’t found.

For example. If you have 20 pages of the custom post type of “recipes” and we have the following template files: archive-recipes.php, recipe-paged.php, recipe-paged-5.php, recipe-paged-15.php.

The chart below shows which pages will use which templates.  Notice that every page 15 and later uses the recipe-paged-15.php file because that is the highest available paged template

recipes/ page/2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
archive-recipes.php recipe-paged.php recipe-paged-5.php recipe-paged-15.php

 

 

If recipe-paged-15.php was missing, then recipe-paged-5.php would be used for all pages from 5 and later.

recipes/ page/2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
archive-recipes.php recipe-paged.php recipe-paged-5.php

 

If recipe-paged-5.php was missing, then recipe-paged.php would be used for all pages (after the first page of course) and if recipe-paged.php is not found, we continue to travel up the hierarchy and use archive-receipes.php, then archive.php ect.

 

Filename matched custom post type templates

Finally, custom post types (CPT) are great and all but sometimes you only need a handful of posts in any given post type. It would be great to be able style a specific post of a given CPT like you would a page.

For example, if you had a post type called “bio”, and a post for “sam-jackson” (the slug) with the id of 454, wordpress will first look for a file “single-bio-sam-jackson.php”, then “single-bio-454.php, single-bio.php and then fallback on wordpress’s default templates to use.

 

In review

So basically, our template hierarchy now looks like this (new templates in orange):

new template hirearchy