WordPress: How to deploy a theme file from your plugin

WordPress is great. We love it. It keeps evolving way faster than Drupal ever did. Well, in the beginning Drupal was great. But for some reason, Drupal died. Anyway. As a South Florida WordPress Development Agency, we get to dig into WordPress pretty deeply. One thing that might not be too obvious to most people, is how do we create a plugin and use a theme file that can be overwritten as needed?

Here’s how:

This function does the following:

  • checks that the template file does not exist in the theme
  • checks to make sure the files exists in the plugin directory
  • if those 2 conditions are met, it uses the plugin file.

This is great because it lets you create a plugin, use the template file from the plugin, and then let the theme developer override the file as needed.

MY_PLUGING_PATH – is the plugin path to your plugin. You should set it like so:

Of course, you would call your plugin whatever your heart desires.

Leave a Reply