Last active
July 18, 2017 16:23
-
-
Save CapWebSolutions/ea7db3801ce1aa4cda3decdaef6790c4 to your computer and use it in GitHub Desktop.
Add Featured Image at top of Single Post/Page in 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 //<= dont add me in | |
| // ref: https://wpbeaches.com/add-featured-image-top-page-genesis/ | |
| // Add featured image on single post | |
| add_action( 'genesis_entry_header', 'themeprefix_featured_image', 1 ); | |
| function themeprefix_featured_image() { | |
| $image = genesis_get_image( array( // more options here -> genesis/lib/functions/image.php | |
| 'format' => 'html', | |
| 'size' => 'large',// add in your image size large, medium or thumbnail, or use below | |
| // 'size' => array(300, 450, true), | |
| 'context' => '', | |
| 'attr' => array ( 'class' => 'aligncenter' ), // set a default WP image class | |
| ) ); | |
| // Extended conditional only prints featured image if set on post. Does not pick the first image. Use 2nd option | |
| if ( is_singular() && ( true === $add_single_image ) && has_post_thumbnail() ) { | |
| // if ( is_singular() ) { | |
| if ( $image ) { | |
| printf( '<div class="featured-image-class">%s</div>', $image ); // wraps the featured image in a div with css class you can control | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment