Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chrdesigner
Created June 17, 2015 14:14
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 chrdesigner/0c8778e991bfd4dbe17d to your computer and use it in GitHub Desktop.
Save chrdesigner/0c8778e991bfd4dbe17d to your computer and use it in GitHub Desktop.
Custom single post format template
<?php
/**
* Custom single post format template
* Reference: https://codex.wordpress.org/Function_Reference/get_post_format
*/
function chr_custom_single_post_format( $template ) {
if ( is_single() && has_post_format() ) {
$post_format_template = locate_template( 'single-' . get_post_format() . '.php' );
if ( $post_format_template ) {
$template = $post_format_template;
}
}
return $template;
}
add_filter( 'template_include', 'chr_custom_single_post_format' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment