Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I made a child theme based on the WordPress twentytwelve theme (i.e., the WordPress 'twentytwelve' theme is its parent).

Some of the modification were done very simply by overriding style, using my own css properties and selectors in the child theme's style.css file (like different property values for the #page div, or whatever).

Other modifications were done by hooks, introducing my own functions in the child theme's functions.php file, and then calling them by placing code in the child theme's (initially duplicated) header.php, footer.php, or wherever. For instance, I added an extra div into each page by writing a new function in the child theme's functions.php which just echoes out the html, and then inserting the call to that function into the appropriate place in the child theme's copy of header.php.

Pretty straightforward stuff, I know. As something of a newbie I was extremely pleased with the results I got - the parent 'twentytwelve' theme was transformed by these child theme modifications into something that looked totally different, and it was just what I wanted. I feel like I could transform the twenty twelve theme into a variety of very different styles.

So far so good. But now I face the question of WordPress updates. When I update WordPress to a new version, or even just the 'twentytwelve' theme to a new version, the hooks (that I placed in my child theme's header.php or footer.php, or wherever) might not work, because the structure of the parent theme's code might radically alter. (I realise that much of it probably wouldn't actually alter, at least for a time, being basic stuff, but some day it might, or I might be tempted to modify code that may more easily become changed.)

So what do I do? I thought of making an exhaustive list of all the modifications I make. That way, when I need to update, I would have to go through each item on the list and check the new files to see whether or not it looks like my modifications would work as before. But that could be pretty time-consuming, and prone to error.

So is there a better way to make all these child theme modifications, and update WordPress core files and themes, without so much trouble?

I suppose I'm looking for some mechanism which makes it easier to check that the modification hooks still work in the child theme's header.php or footer.php, or wherever, when I update WordPress - or which save me from having to do such checks. That's if I have all this right of course!

I get the impression that the 'genesis' framework does this - have I got that right? If so, how does it do it? But why do I have to buy a theme? The modifications I made to WP's 'twentytwelve' theme work very well for me; if possible I'd like to stick with my modification of that theme. Could I use 'genesis' with the 'twentytwelve' theme?

share|improve this question

2 Answers 2

The very concept of child theme is to let your modifications remain intact when updating. You use child theme for maintenance. But it has to be the same theme. I mean Twenty Twelve and Twenty Thirteen are not the same theme.

So basically when theme is updated you do not have to do anything. Regarding WP files updates it should not change anything unless you have hacked the core which is not recommanded.

share|improve this answer
    
My concern was that the parts of the code that get altered when WordPress gets updated or when just a theme gets updated might invalidate my placement of the do_action functions etc that I put into my child theme files (header.php etc). But I get the impression here that this is unlikely. –  John Doe Aug 16 '13 at 21:52

It's true that when you write a theme or a plugin to someone else's software, you are dependent on that software. With each update, it is possible that the base software has changed, and something in your theme or plugin won't work correctly anymore.

That having been said, WordPress as a project does an amazing job of remaining backwards compatible when possible. WordPress rarely removes hooks once they have been added, and when WordPress wants to remove a function, they deprecate it first, providing a warning to the developer for several versions before it is actually removed. Since the Twenty Twelve theme is also written by the WordPress project, you can expect the same attention to detail there.

A plugin or theme developer needs to test his code with each new version of WordPress. Since you are your own theme developer, this falls to you. Familiarize yourself with the debug process. By turning on the WP_DEBUG constant during testing, you will be warned about any functions you are using that have been deprecated and in danger of being removed. For each new version of WordPress, read the codex article that provides an overview of the changes, and look for anything that might affect your software.

share|improve this answer
    
Thanks for the tips (and @JMa). I guess I was thinking that parent themes change more often and more radically than they do. So when I place something like <?php do_action('open_graphic_div_above'); ?> in my child theme's copy of header.php, the place I put it will most likely always remain the appropriate place? TBH I was expecting to get several yells of "use a framework like Genesis to make this all simpler!" But perhaps I don't need to? –  John Doe Aug 16 '13 at 16:06
    
When you use do_action in your child theme, you are adding a hook of your own for someone else to hook into. add_action is the one you use to hook into the WordPress core code. –  Ben Miller Aug 16 '13 at 16:19
    
I don't know anything about the Genesis framework, but creating your own child theme based on one of the WordPress default themes is an excellent way to get started learning about WordPress development. Part of the purpose of these WordPress default themes is to provide an example of robust theme code. If you are happy with the results you are getting with your Twenty Twelve child theme, I don't see a need to force yourself into a framework. If, on the other hand, you were depending some random theme that you found by googling "free themes," then you might want to look for something better. –  Ben Miller Aug 16 '13 at 16:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.