Skip to content

Instantly share code, notes, and snippets.

@maor
Created December 1, 2012 20:22
Show Gist options
  • Save maor/4184748 to your computer and use it in GitHub Desktop.
Save maor/4184748 to your computer and use it in GitHub Desktop.
Add this to your functions.php or functionality plugin
<?php
function my_single_template_by_post_id( $located_template ) {
return locate_template( array( sprintf( "single-%d.php", absint( get_the_ID() ) ), $located_template ) );
}
add_filter( 'single_template', 'my_single_template_by_post_id' );
@barmolino
Copy link

Works Great just you need to create a file in your main template folder with name single-(your post id here).php
Thanks very useful if you want to test some new single.php templates on working website

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment