-
-
Save atelierbram/234a3b0bc0f8dafef27c to your computer and use it in GitHub Desktop.
Add this to your functions.php or functionality plugin
This file contains hidden or 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
<?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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Functions allows for the use of templates for individual WordPress posts, by post-ID. For example:
single-689.php
See also this discussion which encourages the use of custom post-types.