4

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' ) );
4

2 回答 2

19

首先,您需要删除当前存在的标题。所有这些都包含functions.php在您的孩子主题中

remove_action('genesis_header','genesis_do_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 }

我通常会尝试使用相同的类和 ID 名称,这样我就可以保留一些内置样式并为自己节省一些工作,但这取决于你。你所要做的就是在函数中添加你想要的任何东西,然后像这样调用它,

add_action('genesis_header','injectHeader');

希望有帮助!

于 2013-09-17T19:46:50.757 回答
1

刚刚偶然发现这篇文章问了同样的问题。很好的解决方案。使用 Genesis Simple Hooks 插件可以更简单地自定义 Genesis 网站的某些部分。随便搜一下,太棒了

于 2016-11-27T19:25:47.990 回答