wordpress – load a template based on the URI

I assume that your custom post type windows would map onto /windows/ etc?

You can customise the template for individual custom post types via single-posttype.php in your theme, e.g. single-windows.php single-doors.php and single-garages.php WordPress will automatically pick these up

You could also use custom page templates, e.g. page-windows.php or custom templates with the right template names.

If the pages are intended to list the post types, then you could try creating post archive templates, e.g.: http://mark.mcwilliams.me/2010/10/wordpress-3-1-introduces-custom-post-type-archives/

Or, you could create a taxonomy for each of said names, and use taxonomy-windows.php

Using all fo the above, one could share the code using something along the lines of:

<?php
// example code, may need minor modifications
get_template_part('special',$post->post_type);

Allowing you to share the code for all the pages in one file, and giving you child theme support, and the ability to override via files such as special-windows.php

OR, if none of the above suit you, there is a final solution:

http://www.braindonor.net/coding-blog/custom-pages-with-wordpress-plugins/230/

This will let you put a page with whatever you want, wherever you want, without needing any posts or pages of any kind, in a theme independent way.

Leave a Comment