Brad Dalton
Change Hook Position
To change the position your widget displays, simply change genesis_before_content in the code to any other hook position.
// Add Widget Before Content On Specific Page
// Replace the post/page i.d (007) with your own.
genesis_register_sidebar( array(
'id' => 'before-content',
'name' => __( 'Before Content', 'wpsites' ),
'description' => __( 'Content Displays Before Specific Pages Content.', 'wpsites' ),
) );
add_action( 'genesis_before_content', 'wpsites_widget_before_content' );
function wpsites_widget_before_content() {
if ( is_page('007') && is_active_sidebar('before-content') ) {
genesis_widget_area( 'before-content', array(
'before' => '<div class="before-content" class="widget-area">',
'after' => '</div>',
) );
}
}
Add Widget Before Content On Home Page
genesis_register_sidebar( array(
'id' => 'before-home',
'name' => __( 'Home Before Content', 'wpsites' ),
'description' => __( 'Displays Before Content On Home Page.', 'wpsites' ),
) );
/**
* @author Brad Dalton
* @example http://wpsites.net/web-design/add-widget-area-before-content/
* @copyright 2014 WP Sites
*/
add_action( 'genesis_before_content', 'wpsites_widget_before_home' );
function wpsites_widget_before_home() {
if ( is_home() && is_active_sidebar('before-home') ) {
genesis_widget_area( 'before-home', array(
'before' => '<div class="before-home" class="widget-area">',
'after' => '</div>',
) );
}
}
// Add Widget Before Content On All Single Posts
genesis_register_sidebar( array(
'id' => 'before-content',
'name' => __( 'Before Content', 'agency' ),
'description' => __( 'Content Displays Before All Single Posts.', 'agency' ),
) );
/**
* @author Brad Dalton
* @example http://wpsites.net/web-design/add-widget-area-before-content/
* @copyright 2014 WP Sites
*/
add_action( 'genesis_before_content', 'wpsites_widget_before_content' );
function wpsites_widget_before_content() {
if ( is_singular('post') && is_active_sidebar('before-content') ) {
genesis_widget_area( 'before-content', array(
'before' => '<div class="before-content" class="widget-area">',
'after' => '</div>',
) );
}
}
http://wpsites.net/web-design/add-widget-area-before-content/
You can easily change the conditional tag or install the Widget Logic plugin to control where you want to output your widget content.
You can also use this code to add a widget after your content area or after your posts in single posts or all pages of your site.