While writing advanced plugins using custom post types sometimes it becomes necessary to completely take over the display of the particular custom post type display template. While using filters can work for most things sometimes a whole template must be included. One example of this would be if using the custom post type as an endpoint for an api request, where having any additional markup would cause the request to fail.
To include the template from the plugin directory the template_include filter has to be used. The code below will check in the current theme directory before including the one in the plugin folder. This allows for the theme to always be able to override the template. This also shows how to include multiple templates, using simple conditional statements like is_single.