Adding Widget to Wordpress Genesis Theme

70 Views Asked by At

I am working on a Genesis Wordpress theme. What I want is to add a custom header to the theme. How do I get a header selector in the code snipper below?

    // Add support for custom header.
    add_theme_support( 'custom-header', array(
        'width'           => 600,
        'height'          => 160,
        'header-text'     => false,
        'flex-height'     => true,
    ) );
2

There are 2 best solutions below

0
On BEST ANSWER

Adding the following 'header-selector' => '.site-title a', should do the job. So it would like this.

// Add support for custom header.
add_theme_support( 'custom-header', array(
    'width'           => 600,
    'height'          => 160,
    'header-selector' => '.site-title a',
    'header-text'     => false,
    'flex-height'     => true,
) );
0
On

Add the following PHP code to your child themes functions file. Source

genesis_register_sidebar( array(
    'id'          => 'new-widget',
    'name'        => __( 'New Widget', 'domain' ),
    'description' => __( 'Add Content Here', 'domain' ),
) );

add_action( 'genesis_after_header', 'your_widget' );
function your_widget() {

if ( is_front_page() && is_active_sidebar('new-widget') ) {

genesis_widget_area( 'new-widget', array(
    'before' => '<div class="new-widget widget-area">',
    'after'  => '</div>',
        ) ); 

  }

}

This code adds a new widget after the header, To change the position of the widget, change the hook to any other genesis hooks