Konstantin Kovshenin has come up with a neat way to link slugs to Custom Page Templates without manually assigning a template to a page. He’s calling the plugin Static-Templates.

Static-Templates comes in handy when you have a highly customized WordPress site. Ordinarily each Custom Page that needs a slightly different layout needs to be assigned a Custom Template in the WordPress Admin. Using the Template Dropdown to do this when there are a large number of pages is quite cumbersome and error-prone.

Instead what Static-Templates does is it hooks into WordPress’s template_include filter. The filter matches the URL slug, like say art-gallery against a template located at your theme’s static-templates/art-gallery.php file. If the template file is found it’s path gets passed to WordPress’s template loader.

Another cool thing about this technique is that it also ends up saving a Database query! While WordPress needs to access the database to pick up the name of Custom Template, Static-Templates does this merely by convention!

Konstantin built this for a custom project for a friend, but I think it is quite appealing as a general theme customization convention.

Nice work Konstantin. Make it official now, before someone else does!