Wordpress - Themes and Child themes

Wordpress - Themes and Child themes

OK Ive got a Wordpress site that has a theme, and at some time in the past Ive created a child theme and made some changes, all good
BUT, before I knew what I was doing, I made some direct edits on files in the parent theme.

Now I've compared the live sites theme with the original factory default, and the files that have changed are....

footer.php
functions.php
header.php
style.css

So, my question is, If I coped those file to the Themename-Child directory, I should be able to update the theme without anything smashing correct?

The problem is compounded, as in the child theme I also have a functions.php and a header.php file?

From what I've read it's probably using the header.php from the child theme anyway?
But Ive also read that functions.php loads the child and the parent, so Im not sure what to do about that one?

Regards,

Pete
LVL 58
Pete LongTechnical ConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Best to truly fix this by...

1) Run a diff parent + child theme files.

2) Move parent file changes into child theme.

3) They your parent theme updates will work.

Whether or not you can just copy the files from parent -> theme depends on both your parent + theme files.

Likely answer is no... unless you're willing to work through + fix many complex + oddball + difficult to debug problems.
0
Julian HansenCommented:
Not necessarily.

Let's consider the different scenarios (in both cases there is the option that the theme update introduces breaking changes - which you would have to deal with anyway)

1. You updated the parent theme files then you created a child theme and updated those.
Now if you copy the specified files over you do two things
   a) Wipe out your child theme changes
   b) Keep old functionality from prior theme version which may conflict with new theme version

2. You only updated the theme files in the parent
   Similar to the above but you don't run the risk of wiping out your changes

What I would do is get a copy of the theme version you are currently running (before you changed it)

- Run a diff on that vs what you have now
- Make a copy of your child theme folder
- Apply the differences to your child theme copy
- Make a copy of your site but with the unmodified theme (use the version you created the diff from)
- Apply the updated child theme
- Test
- Upgrade theme to new version
- Test
- If all checks out - apply updated theme to existing site and upgrade theme.

(Remember to keep a backup of your last known good setup (files + db) so you have something to go back to if there is a problem.)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
From what I've read it's probably using the header.php from the child theme anyway?
But Ive also read that functions.php loads the child and the parent, so Im not sure what to do about that one?
Both functions.php files are loaded.
child theme functions fired
parent theme functions fired
child theme header fired
child theme footer fired

Open in new window

0
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Pete LongTechnical ConsultantAuthor Commented:
Thanks Guys

>>(Remember to keep a backup of your last known good setup (files + db) so you have something to go back to if there is a problem.)

Way ahead of you there, I've migrated and rebuilt it enough times to be slick at restoring it

Im just taking a closer look at the header and functions php to see the differences
0
Pete LongTechnical ConsultantAuthor Commented:
Got the difference between the Original functions.php and the one in my Master theme.
Then copied that difference to the functions.php file in my child theme.

Site seems to be OK - I will need to flush the caches.

Ill keep an eye on it for a while
0
Pete LongTechnical ConsultantAuthor Commented:
Mmm spoke to soon, The only actual thing thats been added to my functions.php is

function stop_removing_tags(){
    remove_filter('the_content', 'wpautop');
}


add_action('init', 'stop_removing_tags');

Open in new window


Which is a fix for Wordpress removing tags, relocating that into the child themes function.php takes the site down?
0
Julian HansenCommented:
What is in your error log?
0
Pete LongTechnical ConsultantAuthor Commented:
I reversed it an Im back up :)

Ive sat and compared all the changed files and documented the changes, so I know whats where and what Ive changed, with that in mind, I'm going to bite the bullet and update the master theme.

Thanks for both of your assistance today.

Pete
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.