Skip to content

Instantly share code, notes, and snippets.

@atelierbram
Forked from maor/single-id-template.php
Created January 31, 2016 16:00
Show Gist options
  • Save atelierbram/234a3b0bc0f8dafef27c to your computer and use it in GitHub Desktop.
Save atelierbram/234a3b0bc0f8dafef27c 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' );
@atelierbram
Copy link
Author

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.

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