WordPress Voodoo: Custom Post Templates From A Plugin

So you are writing your grand WordPress plugin and you have a custom post type which the user uses, so far so good. You write your single-awesome.php file to allow WordPress to show a view for your custom type and put it into your theme, but wait a second I want my view to be portable! What are my options?

One option is to give up and go along, write a bunch of single-awesome.php files for every major theme (and there are a lot) and on a client basis. However, this is clunky, time consuming and impractical. As the creator of a plug-in, not a theme, you are responsible to have your plugin work, mostly, as is.

There is a better option and that is to include the template files in your theme and to write a add_filter hook to catch whenever a single-*.php template is called and handle your custom post types appropriately. Kenneth Newman at unfocus.com put together a nice post, with code examples, about doing just this. Luckily the code allows for the active theme to override the plugin, which is a good idea considering your template will not fit for all the possible themes out there.

However, we can hand some control of the templates colors, fonts, etc over to the user using a settings page. Currently I am working on an elegant way to do just that and make using my plugin as easy as possible for those who need to use it. Follow up post coming soon