WordPress : Customize Genesis header
Asked Answered
S

2

5

I am just diving into the Genesis Framework.

In a normal theme, if you want to edit the header, you'd open the header.php file.

But in genesis, the header file is not in the child theme. I have looked around and found a way to add custom header support, but i need some guidance.

The code below is to enable custom header support. I assume this goes into the functions.php file. But how to i actually add code here? What if i want to say pull in a custom field, or add a div to this section, or bring a slider in? How to i actually use this code to let me add html and php into the child theme header?

/** Add custom header support */
add_theme_support( 'genesis-custom-header', 
    array( 'width' => 960, 'height' => 100, 'textcolor' => '444', 
          'admin_header_callback' => 'minimum_admin_style' ) );
Selectee answered 16/9, 2013 at 12:48 Comment(0)
G
19

First you need to remove the header that is currently there. All of this goes into functions.php in your child theme

remove_action('genesis_header','genesis_do_header');

Then is it as simple as building a function to act as your new header.

function injectHeader() { ?>
    <div id="title-area">
    <h1>Title Here</h1>
    <nav>Nav Here and so on</nav>
    <p>You can add whatever you want</p>
    </div>
<?php }

I normally try to use the same class and ID names so I can preserve some of the built in styles and save myself some work but that's up to you. All you have to do is add whatever you want in the function and call it back in like this,

add_action('genesis_header','injectHeader');

Hope that helps!

Gammy answered 17/9, 2013 at 19:46 Comment(2)
So helpful, read the docs also but it really helps when someone can explain it in a specific application. I understand it now. Thank you so muchSelectee
Please correct the spelling of header (in second last line :genesis heaader) , copy paste of the code may cause trouble to someone . Thank you .Entophyte
M
1

Just stumbled upon this post asking the same question. Great solution. An even easier way to customize certain parts of a genesis powered site is using the Genesis Simple Hooks plugin. Just do a search, it's awesome.

Milore answered 27/11, 2016 at 19:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.