How to preserve PHP modifications while upgrading WordPress?

Each of the files you have mentioned are theme files. When you upgrade WordPress itself, it will not touch any themes (or plugins) you have installed, whether or not you have modified them.

If this was a theme you created yourself, then you have no worries at all.

However, if this was a theme created by someone else, for example a WordPress default theme, you can still update WordPress… but you need to be careful before updating the theme (if any updates are available for it).

Yes, you can save your modifications and then re-apply them after updating the theme, but the best thing to do is not to make these modifications directly in the first place, and rather use a child theme.

It’s not too hard to set up a child theme, and doing so will mean that any of your modifications are kept safe. Basically, you just copy the pre-existing archive.php, search.php etc., make your modifications, and store them in your child theme’s folder. WordPress will then use these modified files instead of the originals. When you update the original theme, it’s then up to you whether you fold any new changes and enhancements into your child theme.

Leave a Comment