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 a WordPress Expert

Get hourly and project based theme customization, theme tweaks, and development help from world-class WordPress developers at Codeable. If you’re in Kelowna and need a custom website for your business visit our Kelowna Web Design page now to get started.