• Hello,

    I am trying to understand .PHP files and child themes. I need to edit footer.php for my child theme, but the only file in my child theme that I can access is style.css. From what I’ve experienced before, if I copy any code I want to change in my child theme, I can add it to my child theme’s css and it overrides my real themes css. I only copy the speicific code I want to change so that no other css code gets overridden.

    Is the same true for .PHP files? Is it as easy as copying my footer.php into my child theme, deleting all code I dont want to make changes to, and changing the code snippets I need to change? And if so, what if the theme makes any other changes to footer.php in the future? Will copying over the footer.php and editing it override all changes he might make in the future / will that cause any issues?

    Thanks!
    Michele

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @michelesidecar.

    I think that the text below will help you:

    If you want to change more than just the stylesheet, your child theme can override any file in the parent theme: simply include a file of the same name in the child theme directory, and it will override the equivalent file in the parent theme directory when your site loads. For instance, if you want to change the PHP code for the site header, you can include a header.php in your child theme’s directory, and that file will be used instead of the parent theme’s header.php.

    References:
    Child Theme << WordPress Codex

    Thread Starter michelesidecar

    (@michelesidecar)

    Hi @rahmohn , thanks for the response! That definitely helps, but what if the .php file that I want to change has more code in it that I dont want to override ? Can I just delete out all the stuff I dont want to get overridden and just keep my little bit of code that I do? I’m only wondering because if my theme creator makes a change to header.php and I changed one small bit of code, wouldn’t it still override any changes he makes to it in the future?

    Thanks
    Michele

    @michelesidecar

    Yes. Your code going to override all code (including future changes) of the parent theme.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Child themes and .PHP files’ is closed to new replies.