Add After Post Widget

Add after-post widget after posts on your site using the Genesis Framework:

1
2
3
4
5
6
7
8
<?php
 
// Register after-post widget
genesis_register_sidebar( array(
        'id' => 'after-post',
	'name' => __( 'After Post', 'sample' ),
	'description' => __( 'This is the after post section.', 'sample' ),
) );

If you want to add the widget area with the post content area use this code:

1
2
3
4
5
6
7
8
9
// Hook after-post widget to single posts (inside post class)
add_action( 'genesis_after_post_content', 'custom_after_post', ); 
function custom_after_post() {
	if ( is_single() && is_active_sidebar( 'after-post' ) ) {
		echo '<div class="after-post"><div class="wrap">';
		dynamic_sidebar( 'after-post' );
		echo '</div></div>';
	}
}

If you want to add the widget area just below, and outside of the post content area, use this code:

1
2
3
4
5
6
7
8
9
// Hook after-post widget to single posts (outside post class)
add_action( 'genesis_after_post', 'sample_after_post', 9  ); 
function sample_after_post() {
	if ( is_single() && is_active_sidebar( 'after-post' ) ) {
		echo '<div class="after-post"><div class="wrap">';
		dynamic_sidebar( 'after-post' );
		echo '</div></div>';
	}
}