How To Duplicate Files From The Parent Theme To Child Theme

Having a child theme allows you to make changes to your site without changing anything in the original theme’s code. In this post, I will show you how to duplicate files from the parent theme to the child theme easily.

The purpose of a child theme is to be able to modify a parent theme without actually modifying the parent theme file. So that when the parent theme is updated then it does not affect how your site operates.

The way WordPress works is when you have a child theme running, it first looks for a file in child theme before it looks for it in the parent theme.

See also How To Create A WordPress Child Theme Easily

So for example, if you have a header.php file in the child theme WordPress does not look for the file in the parent theme. So whatever you have in the header.php file in the child theme, that’s what the WordPress loads.

For example certain code you can add to header.php file such as google analytics, google webmaster tools, buy sell ads, Facebook open graph, etc which needs to be there all the time even after you update your theme.

See also How To Add Google AdSense Ad Below Navigation Menu without any plugin from your theme header.php.

Another example is that if you did not have the footer.php in the child theme it will load the one from the parent theme.

So you can really mix and match files, you don’t have to completely duplicate the entire parent theme in the child to make changes.

You can duplicate only those files that you want to alter and these should work just fine since the parent theme and child theme works synergistically.

The question comes how can I easily duplicate the parent theme file into the child theme.

If you have any experience with FTP or the file manager in cPanel you already know the answer to this, but in case you don’t have any experience, I am going to show you how to duplicate files from the parent theme to your child theme.

How to Duplicate files from parent theme to your child theme.

I am on the Hostgator host, so I will be showing you my cPanel dashboard. But most hosting cPanel works the same way.

Note: Before you proceed further make sure that you have downloaded/created your theme’s child theme and activated it. Remember the child theme name.

Log on to your hosting cPanel

In the cPanel dashboard scroll down and find the File Manager icon under files and click on that. Make sure to choose the website you are working as the document root.

Duplicate Files Parent Theme To Child Theme

 

This will load all the files of your site. Find the wp-content file and double click on that.

wp content folder

 

Under the wp-content folder click on the themes folder to see all the themes installed on your site.

themes folder

Now click on the child themes folder of your parent theme, you will see only two files, the style.css, and the function.php file.

Duplicate Files Parent Theme To Child Theme

These are images from my cPanel and I am using the Generatepress theme. The above image shows the child theme named as generatepress_child.

The image below shows the default files a child theme will have style.css and functions.php

child theme updated

Now if you want to duplicate the parent themes header.php file to your child theme.

What you have to do is to go back to your main themes folder. In this tutorial, I am showing the Generatepress theme which I am using. In your case, it could be a different theme.

Choose your theme and double click on it, to get the content of the theme. Find the file that you want to duplicate. In this case, I want to duplicate the header.php file.

copy header.phph file

Right-click on the header.php file and from the context menu choose copy. A copy files dialogue box will appear, with the file path already inserted, all you have to do is to enter the name of the child theme at the very end of the file path.

Duplicate Files Parent Theme To Child Theme

Then click on copy files. Now go back to your themes page and check the child theme folder, the header.php file will be there copied from the parent theme.
Duplicate Files Parent Theme To Child Theme
Now you can right-click on the copied header.php file in the child theme and edit the file in whatever you want.

And when WordPress loads the website it will first look if the file exists in the child theme, if it does then it will load it from the child theme.

So if we make any edits in this file header.php in the child theme, it will be loaded and the header.php file in the parent theme will be ignored.

So that how the child theme hierarchy works. That’s how you can quickly and easily copy files from parent theme to a child theme and edit those files without touching any code on the parent theme files.

See also why Google AdSense Not Showing On Some Pages Blank Ads