Reputation:
I have a theme installed and I want to add a header at the top of the existing code. So not to lose it when the theme is updated I'm thinking of creating a child theme and copy the ´header.php` and then edit it in the child theme folder.
So when the theme is updated with changes in the header.php
from the main theme developer, will the file that I copied and changed in the child-theme folder have the updates with the code I added? Or it will remain the same whenever the theme is updated?
I mean to have the updates from the developer and my custom header remains there , So for example if he changed the order of the header elements it will be implemented to the child-theme and my custom header will remain?
Is there is a better way for adding that header without creating a child-theme?
Upvotes: 2
Views: 1228
Reputation: 67768
If the main theme's header.php
is altered by a theme update, the child theme's header.php
won't be touched.
So if there are useful changes in the main theme's header.php
which you want to become effective for your child theme, you'll have to transfer those parts of the code to your child theme's header file by editing it accordingly.
Upvotes: 0
Reputation: 41
Using a child theme is exactly what you need to do. Think of the files in the child theme as an override to what is in the parent theme. If you copy header.php from the parent theme into the child theme and change it, it will load the header.php from the child as opposed to the parent. When you update the parent, the child is untouched. What you're doing is the best way to make your edits without the main theme overwriting your changes.
Upvotes: 1