• mike

    (@mikedekievith2013)


    Hi

    can I edit header.php and prevent it is overwritten in an update ?
    Is a childtheme fit for this ? ( I use twentyfourteen )

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Yeah, a child theme should do the trick.

    Thread Starter mike

    (@mikedekievith2013)

    I need to edit some code in header.php.

    In the WP codex I read
    —–
    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.
    —–

    Now if I understand it rightthe website will use the header.php of the child theme.
    But after like 1 year this will be an old header.php file, and will this still work well with all the other files that have been updated over that year ?
    As I see it I will have an old header.php file with my edited code, in a site where all other files have been updated.
    Or do I see this wrong ?

    Thanks

    Kind of, but this will be an issue only if the child theme became incompatible with the new version of the parent theme, for example :

    there is a function called display_slideshow() and this function belong to the parent theme, you can use it in your child theme but if the parent theme developer update his theme and remove this function and you install the new version then you will see an error saying “the function display_slideshow() is not exist” and then you need to update your child theme header.

    Thread Starter mike

    (@mikedekievith2013)

    ok, that’s clear, thx

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘prevent header.php to be overwritten in update’ is closed to new replies.