WordPress.org

Ready to get started?Download WordPress

Forums

Clean Retina
[resolved] editing header-extensions.php in child theme (2 posts)

  1. Ricky
    Member
    Posted 1 year ago #

    Hi there,

    First of all, I love this theme. Very useful and well designed!

    I'm editing how the header image resizes and to accomplish the desired effect, I need to add a div around the header image in the header-extensions.php file, like this:

    <div id="header-border">
    
    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"><img src="<?php echo $header_image; ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"></a>
    
    </div>	<!-- end header-border -->

    I'm using a child theme and everything was working fine until I reached this point. When I made a copy of header-extensions.php and added it to the child theme folder, it didn't override the existing header-extensions.php file.

    As a test, I edited this file in the parent theme and this extra div works great, but I obviously don't want to edit the parent theme files. What should I do to make the child header-extensions.php file override the parent file?

    Thanks in advance,
    Ricky

  2. robin90
    Member
    Posted 1 year ago #

    Hi Ricky,

    Just making the copy of header-extensions.php file in the child theme will not be able to overwrite the code.
    Only the template files like header.php, footer.php and others are overwritten by the child theme file of the same name but
    not the functionality files.

    You need to unhook the function i.e. cleanretina_headerdetails hooked to cleanretina_header action hook.
    Then add you own function all similar with cleanretina_headerdetails just making the changes that you want
    and hook it to cleanretina_header action hook.
    All this coding can be inside the functions.php file of you child theme.

    Go through this link http://themeshaper.com/2009/05/25/action-hooks-wordpress-child-themes/ , this tutorial shows how its done.

    Rabin

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic