Skip to content

Instantly share code, notes, and snippets.

@srikat
Created October 5, 2013 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save srikat/6837607 to your computer and use it in GitHub Desktop.
Save srikat/6837607 to your computer and use it in GitHub Desktop.
Show Featured Image for Posts and Pages if present, otherwise show responsive slider in Genesis. Details: http://sridharkatakam.com/show-featured-image-present-otherwise-show-responsive-slider-genesis/
<?php
//* Do NOT include the opening php tag
/** Show Featured Image for Posts and Pages if present, otherwise show responsive slider */
genesis_register_sidebar( array(
'id' => 'home-slider',
'name' => __( 'Home Slider', 'eleven40' ),
'description' => __( 'This is the after header section.', 'eleven40' ),
) );
add_action( 'genesis_after_header', 'eleven40_home_welcome_helper' );
function eleven40_home_welcome_helper() {
if ( (is_single() || is_page()) && has_post_thumbnail() ) :
printf( '<div %s>', genesis_attr( 'featured-image' ) );
genesis_structural_wrap( 'featured-image' );
genesis_image();
genesis_structural_wrap( 'featured-image', 'close' );
echo '</div><!-- end #featured-image -->';
else :
if ( is_active_sidebar( 'home-slider' ) ) :
printf( '<div %s>', genesis_attr( 'home-slider' ) );
genesis_structural_wrap( 'home-slider' );
dynamic_sidebar( 'home-slider' );
genesis_structural_wrap( 'home-slider', 'close' );
echo '</div><!-- end #home-slider -->';
endif;
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment