What is the best way to create a custom template for a WordPress Post,  is to create filter in WordPress function.php file.

What is the best way to create a custom template for a WordPress Post,  is to create filter in WordPress function.php file.
What is the best way to create a custom template for a WordPress Post,  is to create filter in WordPress function.php file.
What is the best way to create a custom template for a WordPress Post,  is to create filter in WordPress function.php file.


// Custom template for specific category in wordpress
// If 

function get_custom_cat_template($single_template) {
  global $post;

     if ( in_category( 'news' )) {
        $single_template = get_template_directory( __FILE__ ) . '/single-custom-page-template.php';
     }
  return $single_template;
}

add_filter( "single_template", "get_custom_cat_template" ) ;