Add After Post Widget Area

It's pretty common to add a WordPress widget area at the end of the post. But not every Genesis Child Theme has one this widget area by default. So here's the code snippets needed to make it.

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

// 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:

// Hook after-post widget to single posts (inside entry content)
add_action( 'genesis_entry_footer', 'em_entry_footer_widget', ); 
function em_entry_footer() {
	if ( is_single() && is_active_sidebar( 'after-post' ) ) {
		echo '<div><div>';
		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:

// Hook after-post widget to single posts (outside entry)
add_action( 'genesis_after_entry', 'em_after_entry_widget', 9  ); 
function em_after_entry_widget() {
	if ( is_single() && is_active_sidebar( 'after-post' ) ) {
		echo '<div><div>';
		dynamic_sidebar( 'after-post' );
		echo '</div></div>';
	}
}

Hire WordPress Experts at Codeable.

The only WordPress exclusive freelancer platform that connects thousands of customers with the top WordPress freelance experts to work on projects of any size. 

Free estimate • No obligation to hire • 100% risk-free