I have a WordPress plugin that helps you create call to action boxes. You just select a template from the templates provided by plugin, customize the box using the settings given and publish the box on your site.

All the templates are stored in the /plugin-name/templates/ folder. The plugin has functionality that allows users to add custom templates to the /plugin-name/templates/ folder.

Now the problem is whenever a user uploads a custom template and update the plugin, all plugin files get over written and the template gets removed.

What should I do to prevent this over writing for just the templates folder?

This is how the templates folder look like:

enter image description here

  • You need to change the approach to avoid this problem. Plugin should allow template override from theme. Oct 9, 2014 at 9:17

1 Answer 1


In a nutshell you cannot literally do this. For plugins and themes WordPress erases whole folder on update and unpacks full folder with new version in its place. You could emulate it by temporarily moving folder away and back, but that is inherently faulty solution.

Extension folders are essentially not meant to contain content in them. In more professional environments they very well might be locked down to read only and updates might be managed completely outside of WordPress (via version control or dependency management).

You can (and should) reliably write any content only to WP's content folder.

  • 1
    Is is possible/good practice to add php files inside wp-contents/upload folder? Because my templates are made of a single php file and a couple of images. Also as you said You can (and should) reliably write any content only to WP's content folder. the plugin and it's templates are present in the wp-content folder only. Or you meant something else. Oct 10, 2014 at 6:19
  • @RamShengale yes, uploads folder is pretty much the only one you can easily write to. You can choose to write to wp-content, not inside specific plugin or such, but you'll have to implement Filesystem API for reliable operation (for public code that is, might not care about for private solutions).
    – Rarst
    Oct 10, 2014 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.