Created
January 22, 2014 15:33
-
-
Save madysondesigns/8560821 to your computer and use it in GitHub Desktop.
WordPress Custom Template for a Single Post ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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