• How do I edit the php files (header, footer, etc) of a child theme without running into problems (i.e. having to re-do all my edits) if/when the theme is updated?

    For example, if I edit the parent theme header.php to include some text, I will have to re-insert that once the parent theme is updated. I *could* copy the parent header.php to my child theme and then insert the text. But when the parent theme is updated, I’ll still need to copy the new parent header.php to my child theme, THEN re-insert the text. How do I get around this? Can I make such edits in my style.css (or another file) that will persist through parent theme updates?

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • If you make any edits to the theme’s php templates, these should never be done in the parent theme and always done in the child. If the parent theme is updated, run a diff tool (GUI or CLI) over the two directories, parent and child, to see what changes have been made. You will see your edits as well as any new parent changes. You can then re-create your edits in the new parent template or mirror the parent edits in your child.

    Theme files generally aren’t updated with the same frequency as plugin files so the task of checking for changes shouldn’t be too arduous.

    Thread Starter cag8f

    (@cag8f)

    Thanks Dave. So either way, when my theme gets updated, I have to actively do something (review, edit, etc) to my edited PHP files (as opposed to style.css, which I can leave alone and not worry about). Just want to be sure.

    Yes that’s it. To the best of my recollection (a bit dubious at the best of times) I’ve never had an issue with an updated parent theme affecting a child. Nevertheless, I always run a diff tool, just to see what changed anyway.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Edit php child theme’ is closed to new replies.