我确实重新定位了<header>
在“wrap class”类之外,通过在我的函数中添加此函数。php
/** Reposition header outside main wrap */
remove_action( \'genesis_header\', \'genesis_header_markup_open\', 5 );
remove_action( \'genesis_header\', \'genesis_do_header\' );
remove_action( \'genesis_header\', \'genesis_header_markup_close\', 15 ) ;
add_action( \'genesis_before\', \'genesis_header_markup_open\', 5 );
add_action( \'genesis_before\', \'genesis_do_header\' );
add_action( \'genesis_before\', \'genesis_header_markup_close\', 15 );
/** Reposition header outside main wrap */
remove_action(\'genesis_after_header\',\'genesis_do_nav\');
add_action(\'genesis_before\',\'genesis_do_nav\');
我的“header”980px宽度为
margin:0 auto;
#header {
border-bottom: 2px solid #1e1e1e;
min-height: 120px;
overflow: hidden;
width: 980px;
margin:0 auto;
padding: 0 0 10px 0;
}
当我检查inspect element时,我看到了这一点。
<body>
<header>Some text here</header>
</body>
我想要的是在标题中添加一个全宽的包装器
<body>
<div class="hwrapper"><header>Some text here</header></div>
</body>
.hwrapper { width: 100% ; background-color:#000;}
是否有一个钩子或函数可以做到这一点?????
最合适的回答,由SO网友:Charles Clarkson 整理而成
这应该可以做到。我现在不能测试它。
我用了genesis_header_markup_open()
以及genesis_header_markup_open()
Genesis函数并将其重命名wpse_121660_header_markup_open()
和wpse_121660_header_markup_close()
. 然后调用它们而不是Genesis函数,并添加新的<div>
在他们身上。
/** Reposition header outside main wrap */
remove_action( \'genesis_header\', \'genesis_header_markup_open\', 5 );
remove_action( \'genesis_header\', \'genesis_do_header\' );
remove_action( \'genesis_header\', \'genesis_header_markup_close\', 15 ) ;
add_filter( \'genesis_before\', \'wpse_121660_header_markup_open\', 5 );
add_action( \'genesis_before\', \'genesis_do_header\' );
add_filter( \'genesis_before\', \'wpse_121660_header_markup_close\', 15 );
/** Reposition header outside main wrap */
remove_action(\'genesis_after_header\',\'genesis_do_nav\');
add_action(\'genesis_before\',\'genesis_do_nav\');
/**
* Echo the closing structural markup for the header.
*
* @uses genesis_structural_wrap() Maybe add closing .wrap div tag with header context.
* @uses genesis_markup() Apply contextual markup.
*/
function wpse_121660_header_markup_close() {
genesis_structural_wrap( \'header\', \'close\' );
genesis_markup( array(
\'html5\' => \'</header></div>\',
\'xhtml\' => \'</div></div>\',
) );
}
/**
* Echo the opening structural markup for the header.
*
* @uses genesis_markup() Apply contextual markup.
* @uses genesis_structural_wrap() Maybe add opening .wrap div tag with header context.
*/
function wpse_121660_header_markup_open() {
genesis_markup( array(
\'html5\' => \'<div class="hwrapper"><header %s>\',
\'xhtml\' => \'<div class="hwrapper"><div id="header">\',
\'context\' => \'site-header\',
) );
genesis_structural_wrap( \'header\' );
}