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

nokul
  • 105
  • 2

1 Answers1

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

Pieter Goosen
  • 55,488
  • 23
  • 117
  • 211