An important concept in WordPress plugin development is to enable sites (and developers) to customize any output that is rendered on the front-end. This is done using templates. We can term the template shipped with your plugin as “base templates” or “original templates”. These should be complete and provide a good standard or generic render of the content or data, whatever the purpose of the template is. Just as importantly, they should serve as a solid base for developers to extend at the theme layer.

There are quite a number of filters and conventions involved in WordPress theming. For most situations though, it’s actually fairly simple. If your plugins makes CPT’s (Custom Post Types) for instance, you’ll want to provide a “single template” (aka Single Post Template). At the theme layer this would be single.php. But in most situations custom plugins have data or content that won’t render in single.php which is why it’s important to ship a custom template instead. To do this you’ll implement the filter “single_template”. Then inside your callback for the single_template filter use locate_template() to find if your base template has been overridden. This use of locate_template can also be used for other types of templates you might be shipping in the plugin, the only thing that will change is what filter you will call. And for entirely custom templates that are not part of the WordPress template hierarchy, you’ll still want to use locate_template() before loading in order to provide that option to override the template at the theme layer.

From a philosophy standpoint, plugins are not supposed to create the rendered output and do significant styling. That’s the job of the theme layer. At least that’s the theory behind having a theme layer in WordPress and most other CMS systems. In reality plugin developers are expected to deliver something that is ready for use, and that includes some level of reasonable UX quality. If for instance you said here is my plugin that provides a business directory, but it doesn’t have a single template so you’ll have to build that yourself… this isn’t going to become a very popular plugin especially with end-users that don’t code, and with agencies that also increasingly avoiding custom coding. Your base templates and the styles you ship with them should be as complete as possible, as high quality as possible. Yet at the same time you have to find the balance to avoid creating something that starts to trump the styles that should come from the theme. You know you’ve got the balance right when you can test your templates on a range of different themes and see the theme taking control but the layout is still solid without any obvious flaws.