Skip to content

Instantly share code, notes, and snippets.

@gezimbasha
Created October 3, 2013 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gezimbasha/6811910 to your computer and use it in GitHub Desktop.
Save gezimbasha/6811910 to your computer and use it in GitHub Desktop.
Adds the single-id.php to WordPress Template Hierarchy.
function get_single_template() {
$object = get_queried_object();
$id = get_queried_object_id();
$templates = array();
if ( $object )
$templates[] = "single-{$object->post_type}.php";
if ( $id )
$templates[] = "single-$id.php";
$templates[] = "single.php";
return get_query_template( 'single', $templates );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment