I was working on my 1.5 site and thought that being able to define separate templates for Pages was pretty sweet. Makes working with themes really nice. (ie, get_page_template();)
Then I notied it could be done for category listing by using a file called category-CATNAME.php. Cool.
However, there was a distinct lack of this kind of feature for individual posts. SOOO, I think that this should feature should be in there. It's a pretty quick hack, and for the most part covered.
Summary: Allows individual posts to use a specialy defined template.
Open wp-blog-header.php line 234:
} else if ( is_single() && file_exists("$wp_template_dir/single.php") ) {
include("$wp_template_dir/single.php");
exit;
Change this to:
/* edited to allow PER POST templates - see also: wp-includes/functions.php */
} else if ( is_single() && file_exists(get_post_template()) ) {
include(get_post_template());
exit;
/* End addition */
Now, open up wp-includes/functions.php goto 1466 and add a new function:
function get_post_template() {
global $wp_query;
$id = $wp_query->post->ID;
$template_dir = get_template_directory();
$default = "$template_dir/single.php";
$template = get_post_meta($id, "wp_post_template", true);
if (empty($template)) {
return $default;
}
if (file_exists("$template_dir/$template")) {
return "$template_dir/$template";
}
return $default;
}
(You'll notice get_page_template() is at line 1448 )
Now to use this, I didn't make a fancy drop down or anything like that for the post page like there is on the Page, er, page. However, you can just set the meta key "wp_post_template" with a value of something like "special.php" and if there is a special.php it will use that, if not it will default to single.php, or index.php in case of crazy failure.