将外包装添加到我的页眉,并使其全宽

时间:2013-11-08 作者:Jeremi Liwanag

我确实重新定位了<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;}
是否有一个钩子或函数可以做到这一点?????

1 个回复
最合适的回答,由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\' );
}

结束

相关推荐

Implement Hooks Using Array

我试图在一个主题中实现一些钩子,但不是用重复的代码写出每个钩子,而是想知道是否可以使用和数组来声明钩子。E、 g.通常,我会使用类似以下内容:function hook_name_1() { do_action( \'hook_name_1\' ); } function hook_name_2() { do_action( \'hook_name_2\' ); } 有没有办法将钩子名称放入一个数组中,然后用一个foreach循环

将外包装添加到我的页眉,并使其全宽 - 小码农CODE - 行之有效找到问题解决它

将外包装添加到我的页眉,并使其全宽

时间:2013-11-08 作者:Jeremi Liwanag

我确实重新定位了<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;}
是否有一个钩子或函数可以做到这一点?????

1 个回复
最合适的回答,由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\' );
}

相关推荐

Organize functions.php

组织职能的最佳方式是什么。php的性能?我有几个add\\u操作调用、几个add\\u主题支持、几个add\\u过滤器和4个附加函数。对于面包屑、样式表、注册菜单和小部件。我们是否需要遵守订单?例如,首先是所有add\\u过滤器函数,然后是add theme\\u support等。不确定添加代码是否相关,因为这是一个一般性问题。如果需要,我很乐意更新这篇文章。