Single page template for custom post_type

I had the same problem. Why WordPress doesn’t automatically use the custom single.php template is above me. That aside, here is the code I’m using to force my CPT to use my custom single.php. Just change the CPT and template name to suite your needs.

    <?php
   /* Information Posts Template selection - a single.php just for our information posts */
function pietergoosen_info_template_include( $original_template ) {
    if ( isset( $wp->query_vars['information'] ) && false == $wp->query_vars['information']  ) {
        return get_template_directory() . '/single-information.php';
    } else {
        return $original_template;
    }
}

add_filter( 'template_include', 'pietergoosen_info_template_include' );

    ?>

Leave a Comment