Use Child Themes and Plugins
A lot of newcomers to WordPress dive right in and start modifying their core theme files. This is a definite mistake. All of your changes will disappear right after an upgrade, and since plugins and themes are updated about as often as apps on your phone, this is pretty frequently.
To avoid this, create children of your plugins and themes. Not only will you preserve your changes, you can upgrade on your own time. The same steps used to create a child theme can be applied to creating a child plugin, but let’s use creating a child theme as our example.
To get started making your child theme, create a new folder in your themes folder with a unique name, then create a
style.css file in your new folder.
In WordPress, all theme parameters are stored in the
style.css file as the first comment block. Open the
style.css from your original theme, the parent, to see an example of this.
For your child theme, go ahead and copy that comment block from your original theme’s
style.css to the new file and rename it. Adding the
template parameter to this header will link your new theme to the original. The Template parameter should point to the folder name of the original theme, like so:
Theme Name: Twenty Fourteen Child Theme
Description: My new child theme based on Twenty Fourteen
Now, if you want to modify files of the original theme, copy them from the original theme’s folder and paste them into your child theme folder. WordPress will use original template files unless it sees the same file in your child theme. So if you want to make changes to
header.php, copy it from your original theme into your new child theme folder, and make the changes in the copy. For adding new or modified code, you likewise create a new functions file in your child theme and make your changes there.
This same file copying strategy goes for many plugins as well: create a folder with the same name as a plugin inside your child theme, and then adhering to the file structure of the original plugin folder, copy files from the original plugin to your new folder and modify them. Most major plugins support this, but it’s always good to check with the author if you are not sure.