This code adds a new widget ares which displays on your home page.
You home page is your posts page according to your Reading Settings.
If you want to add a new widget after the header on your front page, use the second code snippet.
Add the code to the end of your child themes functions.php file using a code editor.
Widget After Header On Home ( Posts Page )
genesis_register_sidebar( array(
'id' => 'custom-widget',
'name' => __( 'Custom Widget', 'genesis' ),
'description' => __( 'Custom Widget Area', 'childtheme' ),
) );
add_action( 'genesis_after_header', 'home_page_widget' );
function home_page_widget() {
if ( is_home() ) {
genesis_widget_area( 'custom-widget', array(
'before' => '<div class="custom-widget widget-area">',
'after' => '</div>',
) );
}
}
Widget After Header On Front Page
genesis_register_sidebar( array(
'id' => 'custom-widget',
'name' => __( 'Custom Widget', 'genesis' ),
'description' => __( 'Custom Widget Area', 'childtheme' ),
) );
add_action( 'genesis_after_header', 'front_page_widget' );
function front_page_widget() {
if ( is_front_page() ) {
genesis_widget_area( 'custom-widget', array(
'before' => '<div class="custom-widget widget-area">',
'after' => '</div>',
) );
}
}
Was This Tutorial Helpful?