/* * @package WordPreciousss * @subpackage Custom_Single_Templates_Code Description: This php code let your WordPress theme use Custom Single Templates as described in http://wordpreciousss.org/support/custom-single-templates-in-precious/ Usage: Copy the function below to your theme's functions.php file Note: The code is included in Precious Parent Theme http://wordpreciousss.org/themes/precious/ so you _do not_ need to add this to any child themes of Precious */ /* Copyright (c) 2009 Kristin K. Wangen http://wordpreciousss.org/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /*start coying*/ function themename_single_template() { global $wp_query; $id = (int) $wp_query->post->ID; $template = get_post_meta($id, 'single_template', true); if ( 'default' == $template ) $template = ''; $templates = array(); if ( !empty($template) && !validate_file($template) ) $templates[] = "single-$template.php"; $templates[] = "single.php"; return locate_template($templates); } add_filter('single_template','themename_single_template');