• Resolved AJD

    (@ajd)


    I need to make a small structural change to the header by adding an additional div between the hgroup-wrap div and the page-title-wrap div.

    This is super easy if I hack the inc/structure/header-extensions.php file… At line 835 I pasted this:

    <!--Custom theme hack to insert the featured image as header for the page  -->
            <?php if ( !is_single() )
    			{ echo ' <div class="featured-header-wrap"> ';
            if ( has_post_thumbnail() ) {the_post_thumbnail();}
    			echo '</div>';
    		  } ?>

    However I would like to do it the proper way.

    I tried recreating the inc/structure/ directory in my child theme and pasting a modified header-extenstions.php file there and tried pasting it in the root of my child theme. That didn’t work.

    I also tried unhooking the entire interface_headercontent_details() function and re-hooking my own version in my child theme’s functions.php. Like this:

    remove_action( 'interface_header', 'interface_headercontent_details', 10 );
    
    add_action( 'interface_header', 'my_interface_headercontent_details', 12 );

    However, this landed up creating two headers…

    Does anyone have any ideas how to do this?

    Thanks!
    AJ

Viewing 6 replies - 1 through 6 (of 6 total)
  • I have exactly the same problem. Can anyone help?

    Thread Starter AJD

    (@ajd)

    Okay, I got this to work by unhooking the interface_headercontent_details function and hooking in my own. I had the priority wrong in my first attempt.

    //first remove the original function
    
    function remove_interface_header_details() {
    	remove_action( 'interface_header', 'interface_headercontent_details', 10 );
    }
    add_action('interface_header','remove_interface_header_details' , 9 );

    Then copy and paste the entire interface_header_content_details function and action hook from header-extensions.php into the child theme functions.php. Rename the function and action hook and make your edits:

    add_action( 'interface_header', 'my_interface_headercontent_details', 10 );
    function my_interface_headercontent_details() {
    PASTE THE CUSTOMIZED FUNCTION HERE. The main HTML structure is at around line 835.
    }

    i have the same problem

    i need to add SMS link in top info bar

    Thread Starter AJD

    (@ajd)

    Per the post above the only way I can see to customize the header is to unhook the function and rehook your own version.

    And it works perfect?
    You have Sample URL I can see?thanks for reply

    Thread Starter AJD

    (@ajd)

    It is on a site in development, but here is a pastebin of the raw code that goes into functions.php. It is a lot of code, but we are recreating the entire interface_headercontent_details() function which is very long.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to add a new div in the header?’ is closed to new replies.