Assign single template to multiple custom post types?

You can filter template_include and pass your custom template as return value depending on your own conditions.

Sample code, not tested:

add_filter( 'template_include', function( $template ) 
{
    // your custom post types
    $my_types = array( 'photography', 'painting' );
    $post_type = get_post_type();

    if ( ! in_array( $post_type, $my_types ) )
        return $template;

    return get_stylesheet_directory() . '/single-photography.php'; 
});

Leave a Comment