• Resolved Unicornflakes

    (@unicornflakes)


    I want to insert a header image directly in my child theme directory, that overrides the parent’s header image.

    I have tried to copy the header.php to my child theme directory and added a link to my image, like this:

    <div class="header section" style="background-image: url(<?php if (get_header_image() != '') : ?><?php header_image(); ?><?php else : ?><?php echo get_template_directory_uri() . '/images/sunset-691204_1280.jpg'; ?><?php endif; ?>);">

    I have also put the image in the images directory.

    But the header.php does not override the parent theme’s header.php file.

    Should I put some code in the beginning of the header.php file as I did with the css file, to make it import the parent files settings? Do I need to do something more to make it work?

    I use the Hemingway theme downloaded from here: //www.andersnoren.se/teman/hemingway-wordpress-theme/

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

    (@bdeaton108)

    If you are working with a child theme, you will want to copy all contents from the original header.php file in the parent theme to a file in your child theme folder of the same name. After you have the header.php file in your child theme folder, you can then open and edit the contents.

    Thread Starter Unicornflakes

    (@unicornflakes)

    That is what I did. I copied the entire file and put it in my child theme folder. It still does not override.

    Do I need to add something in the functions.php to make it load the other php files?

    Brett

    (@bdeaton108)

    Not necessarily. Not insulting your intelligence here, but you have activated the Child theme, correct?

    One possible issue is that you’re calling get_template_directory_uri(), which refers to the parent theme folder if you’re using a child theme. Instead, you should call get_stylesheet_directory_uri(), which refers to the child theme’s folder.

    Thread Starter Unicornflakes

    (@unicornflakes)

    YAY! Thank you stephencottontail, it worked! ??
    *happy dance*

    Btw, no offence taken Brett, that could have been the issue, I just recently learned how to activate child themes ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to make child theme header.php override parent?’ is closed to new replies.