How would I best phrase the WordPress question below? The question I have composed is flagged by Stack Exchange as, "The question you're asking appears subjective and is likely to be closed." The title and text are below:


Title

"When copying a theme file to my child theme for edits, how do I best handle future theme updates?"


Question

I need to make a customization to my theme, and the best way to do so seems to be to edit a theme template (i.e. copy the template from parent theme to child theme, then edit the child theme template). I know this is not uncommon practice. But what is best practice when doing so, especially when the template in-question is updated?

I ask because the issue with this technique is: when the theme is updated, and this particular template is updated, I have to take extra steps to incorporate my edits into the new theme file. I'm not saying my template will be overwritten--I'm saying I will continue to use the old version of the template. How do I best use the new version of the template, that contains all the edits I made to the old version? My current method is to compare the two files using a diff-tool, and manually incorporate my edits into the new template. But that can be quite a bit time consuming for more extensive edits. And if another developer works on the site in the future, unless I've handed over very detailed notes, updating the theme could cause big issues for that developer that they'll have to painstakingly track down (I recently worked on a site with this problem). I'm just wondering if there is a better way that I am perhaps overlooking.

Ideally I make edits via my child theme's style.css or functions.php. If those aren't possible, for smaller edits, I sometimes write custom JavaScript. But the edits in this case will almost certainly have to be made to one (or more) theme PHP templates.

up vote 2 down vote accepted

I think the problem here is that it's asking for best practices, it isn't a question, but rather a prompt for a discussion.

You need to be able to mark an answer as THE answer, not just the one that best worked for you this time around. My inclination would be to close vote as primarily opinion based as there are no right or wrong answers

Not all questions fit well into the QA format, nor would this format provide the best result for all questions. For some questions it works very well, but in this case it falls into the "it depends on your preference"

For example, in your case, you'd probably want to double check the parent file every now and again for updates. You might do this via git, but you might do this via a test server to check if things break when the theme updates, rather than tracking the individual files themselves. Multiple options, all work, all valid, and that's not a complete list either.

  • OK. In light of that, I understand that this question is probably not suited for Stack Exchange. Do you have any ideas where would be better suited? I've already asked it to the official WordPress forums (no replies), and the WordPress sub-reddit (a couple replies). – cag8f Apr 11 at 14:41
  • Therein lies the other problem with your question, not a stack exchange problem, but the one of open ended questions and nobody wanting to look a fool – Tom J Nowell Apr 11 at 14:43
  • Got it, thanks. I have a feeling you've used WordPress once or twice. How do you handle this issue? Do you simply refrain from modifying theme files in this manner? Or do strive to use themes with plenty of hooks to be used for such customization (so you avoid situations like the one I described)? Or do you fix update issues only when they arise? You mentioned updating on a test server to check if things break. That is my typical course of action. It just seemed a bit inelegant is all, given all the elegance around it. That was my motivation for asking. – cag8f Apr 11 at 14:53
  • It's never an issue I've encountered, theme updates should only provide bugfixes, if they change enough that they break child themes then that's irresponsible of the original author – Tom J Nowell Apr 11 at 16:06
  • That's a helpful point. I've encountered one issue in which a theme update broke my child theme in this manner. So that's why I've been mindful of such issues, and been reluctant to copy theme files to my child theme. But now that you say that these issues shouldn't occur, maybe my one case could have been an anomaly. The impetus behind this is that I actually have a current project in which it appears that editing theme templates in this manner is unavoidable, so I came here to determine once and for all whether doing so is something I can/should do without too much concern. – cag8f Apr 12 at 2:04
  • Basically all solutions involve testing and/or code review from the point of the child theme – Tom J Nowell Apr 12 at 12:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .