• Hi,

    this can not be difficult, but I searched and searched and I can not seem te find the answer anywhere so here it goes.

    I have installed a child theme and it works fine, but now I want to make a small modification to the header.php.

    I made a new header.php file and uploaded it into my child-theme folder and that to works fine, but…

    Since it is just a small mod on the original header.php in stead of copying the whole file into the new header.php I would like to just include the original header.php and only put my modification into the new file.

    In case I am not making sense:
    In the same way you use @import url(“../twentytwelve/style.css”); in the style.css.

    Can I use a ‘include’ or a ‘require’? I am not a php expert, but this should be possible right?

    Thank you in advance for your help!

    Kind regards,

    Pike

Viewing 5 replies - 1 through 5 (of 5 total)
  • Just download the parent theme’s header.php and upload to child theme folder with your edit. You can do this for any of your theme’s template files, like page.php, sidebar.php, footer.php etc.

    Thread Starter Pike80

    (@pike80)

    Hi thanks for your reply.

    I know that works indeed. But when I copy the parentstheme header.php with all its content it replaces the original header.php.

    When the original header.php is improved in a new version of the template and I install that new version of the template, my child-theme will still have the old unimproved header.php. You get what I mean?

    Same reason that you use @import url(“../yourparenttheme/style.css”);, in stead of downloading / copying the whole style.css of your parent theme to your child theme.

    I hope I explain this correct, since I am not a native english speaker.

    Thanks!

    You cannot import a theme template file in the same way that you import a stylesheet. You must use the complete header.php in your child theme.

    When the original header.php is improved in a new version of the template and I install that new version of the template, my child-theme will still have the old unimproved header.php. You get what I mean?

    This would be wholly theme dependent and you would need to discuss with theme provider…If you start with a good theme built on current theme design standards, this should not be an issue. Your theme should provide basic site layout and CSS…when the theme is heavy with other options is when you run into issues, which is why you will see so often in this forum to use default unedited theme and a child theme (then some well used and trusted plugins for other functionality).

    Files such as I noted, header, sidebar, footer, content, page, should not need to change from theme version to theme version…with a well designed theme.

    Thread Starter Pike80

    (@pike80)

    ok too bad.

    thanks for your answer Esmi. I was hoping that I could use the ‘include’ function of php, but I guess that is no option.

    thanks again!

    Pike

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘How to include original header.php file when using child theme’ is closed to new replies.