Skip to content

Instantly share code, notes, and snippets.

@neilgee neilgee/double-header.php
Last active Aug 29, 2015

Embed
What would you like to do?
Genesis Header Widget Duplication on Condition
<?php
//Add in new Header Right area
function cgp_extra_widgets() {
genesis_register_sidebar( array(
'id' => 'HeaderRight2',
'name' => __( 'headerright2', 'genesischild' ),
'description' => __( 'This is the Header Right2 Position', 'genesischild' ),
) );
}
add_action( 'widgets_init', 'cgp_extra_widgets' );
function cgp_add_second_header_right() {
if (is_single('') && in_category('red') ) {
remove_action( 'genesis_header', 'genesis_do_header' );
add_action( 'genesis_header', 'cgp_special_header' );
}
function cgp_special_header() {
//my new header code
genesis_markup( array(
'html5' => '<div %s>',
'xhtml' => '<div id="title-area">',
'context' => 'title-area',
) );
do_action( 'genesis_site_title' );
do_action( 'genesis_site_description' );
echo '</div>';
genesis_markup( array(
'html5' => '<aside %s>',
'xhtml' => '<div class="widget-area header-widget-area">',
'context' => 'header-widget-area',
) );
do_action( 'genesis_header_right' );
add_filter( 'wp_nav_menu_args', 'genesis_header_menu_args' );
add_filter( 'wp_nav_menu', 'genesis_header_menu_wrap' );
dynamic_sidebar( 'headerright2' );
remove_filter( 'wp_nav_menu_args', 'genesis_header_menu_args' );
remove_filter( 'wp_nav_menu', 'genesis_header_menu_wrap' );
genesis_markup( array(
'html5' => '</aside>',
'xhtml' => '</div>',
) );
}
}
add_action('get_header', 'cgp_add_second_header_right');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.