Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.