Created
October 5, 2013 06:56
-
-
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/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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