Skip to content

Instantly share code, notes, and snippets.

@braddalton
Last active March 7, 2017 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braddalton/4741976 to your computer and use it in GitHub Desktop.
Save braddalton/4741976 to your computer and use it in GitHub Desktop.
Add Widget Before Content On Single Page In Genesis Using Conditional Tag
// Register before-content widget
genesis_register_sidebar( array(
'id' => 'before-content',
'name' => __( 'Before Content', 'agency' ),
'description' => __( 'This is the before-content section.', 'agency' ),
) );
// Hook before-post widget to single page
add_action( 'genesis_before_content_sidebar_wrap', 'custom_before_content', 9 );
function custom_before_content() {
if ( is_page('386') && is_active_sidebar( 'before-content' ) ) {
echo '<div class="before-content"><div class="wrap">';
dynamic_sidebar( 'before-content' );
echo '</div></div>';
}
}
//Add Widget Before Content On Single Page with I.D 386
//Change the conditional tag to suit your needs
@ali-smith
Copy link

thank you! worked like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment