I'm attempting to register a new widget area in my Genesis child theme for WordPress. The code doesn't seem to be working and crashes my site. Can anyone tell me what I'm doing wrong here? I'm trying to get it above the content on all pages. This is the code I have:
genesis_register_sidebar( array(
'id' => ‘above_content’,
'name' => __( ‘Above Content’, 'domain' ),
'description' => __( ‘Above the content’, 'domain' ),
));
add_action( 'genesis_before_loop’, ‘above_content’ );
function your_widget() {
if ( is_active_sidebar(‘above_content’) ) {
genesis_widget_area( ‘above_content’, array(
'before' => '<div class=“above_content widget-area">',
'after' => '</div>',
));
}
}
Two things:
'
, not curly quotes ‘
genesis_register_sidebar( array(
'id' => 'above_content',
'name' => __( 'Above Content', 'domain' ),
'description' => __( 'Above the content', 'domain' ),
) );
add_action( 'genesis_before_loop', 'your_widget' );
function your_widget() {
if ( is_active_sidebar('above_content') ) {
genesis_widget_area( 'above_content', array(
'before' => '<div class="above_content widget-area">',
'after' => '</div>',
) );
}
}
If you want to register another widget, just register a new sidebar (with a unique ID), and add new logic to a new callback function (or add it to your_widget()
). Where you add this additional widget depends on your specific use case.