Skip to content

Instantly share code, notes, and snippets.

@madysondesigns
Created January 22, 2014 15:33
Show Gist options
  • Save madysondesigns/8560821 to your computer and use it in GitHub Desktop.
Save madysondesigns/8560821 to your computer and use it in GitHub Desktop.
WordPress Custom Template for a Single Post ID
// Hook into the single_template filter to use a custom template for one particular
// post and still have it appear in the regular blog archives, featured posts, etc.
// Template should be named 'single-[postID].php.
add_filter('single_template', 'widget_custom_post');
function widget_custom_post($template) {
global $post;
// If it's the desired post, override the standard template with custom.
// Repeat this if you want to override multiple posts.
if ($post->ID == '16033') {
$template = dirname( __FILE__ ) . '/single-' . $post->ID . '.php';
}
return $template;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment