The Question of the Week today falls under the “Advanced WordPress” category. Anytime you get into functions.php I think that’s more advanced than the average user – don’t you?
My good friend Matt asked
“Mike Mueller I figured you’d be a good person to ask…if you have a child theme (Genesis parent) in WordPress, is it possible to add functions without adding to functions.php…like some sort of “grandchild” theme technique? I know what and how I want to change something and even know it works, but wanted to know if there was a way to “protect” that code in case there was an update.“
The reason Matt is asking this is because he knows the 1st Rule of WordPress.
The function.php file is the place where you can mod a bunch of stuff if you are trying to make a theme work better for your needs. It controls things like the size of your logo, widget boxes, menu bars and so much more.
EXTREME CAUTION: Misplace just one character in your code, you’ll end up locked out of your site – so you need to be very very careful. The best way to make changes is via FTP or a File Manager.
Matt’s concern is that when he makes the changes he wants, if there’s an update to that theme, it’ll wipe out his changes. That’s absolutely true, he’s right.
The theme files that come with an update generally include and replace the existing ones. That said, Genesis Child themes hardly, if ever need an update. WordPress Core does so, as does Genesis itself but the child themes. The key word is “HARDLY”. It does and can happen.
- You could simply keep a copy of the Functions.php file handy in your hard drive somewhere, or
- There are plugins that will allow you to addon to your file (but I haven’t used them), or
- Another way around this, to be totally safe, would be to create your own child theme.
I work on the WordPress.org Training Team. We are creating lesson plans for people to teach WordPress with. One of the plans we have is on creating a Child Theme. Check out the work we’re doing!
RELATED: When it comes to modifying the CSS – the same rules apply. Never mess with the themes style.css – always use an addon. JetPack has one and then there are plugins that will do the same.
I hope that answers your question Matt.
- The Ultimate Guide to Writing the Perfect Blog Post - March 14, 2023
- 8 Questions Your Web Developer Should Have Asked - April 27, 2021
- Slack, Chat or Discord? - April 6, 2021