0

I have written several own shortcode scripts which I place in the shortcodes.php file. My Wordpress installation is set to update to new Wordpress versions automatically, which is a good thing.

But the Wordpress updates keep overwriting the shortcodes.php file, so I have to manually add my shortcode PHP code every time after an update (and I might be away a few days or so).

Which is the preferred place to put my PHP code for the shortcodes that does not get overwritten?

Thankfully nokul

2
  • Is this a plugin? A theme? The file in the WordPress core?
    – fuxia
    Commented Jul 26, 2015 at 9:46
  • Add custom PHP via a child theme or functionality plugin. Commented Jul 26, 2015 at 11:04

1 Answer 1

2

NEVER EVER alter any template or file in a theme or plugin that you did not author, and this goes for any core file as well. There is no way to protect the code that you alter or add in any of those files, except maybe changing file permissions, but then again, you will run into other issues

ALL customizations should and must be made in either a child theme or a custom plugin. Code like shortcodes as in your question must always go into a custom made plugin as shortcodes add functionality to your site and not your theme.

You should definitely go and read the following post

This is one of the most important things that you need to consider when customizing anything for a site

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.