ControlledChaos
7/4/2015 - 6:10 AM

Get single-{post-format} templates. The files need to be in the theme root directory.

Get single-{post-format} templates. The files need to be in the theme root directory.

<?php

function ccd_post_format_templates( $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', 'ccd_post_format_templates' );

?>

Get single-{post-format} templates

WordPress Snippet