Last active
September 3, 2017 14:14
-
-
Save carasmo/c65e4b609400629ba24922335dc283e5 to your computer and use it in GitHub Desktop.
How to get Featured Image 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 | |
// don't add again | |
add_action( 'genesis_entry_content', 'your_prefix_featured_image', 5 ); | |
/** | |
* Show Featured Image on post and pages and a CPT if you got one (add to the array) | |
*/ | |
function your_prefix_featured_image() { | |
if ( ! has_post_thumbnail() || ! is_singular() ) return; | |
$caption = get_post( get_post_thumbnail_id() )->post_excerpt; | |
if ( is_singular( array( 'post', 'page' ) ) ): | |
if ( ! empty( $caption ) ) : | |
$caption = sprintf( '<figcaption>%s</figcaption>', $caption ); | |
endif; | |
$image = genesis_get_image( array( | |
'format' => 'html', | |
'size' => 'featured-image', | |
'context' => '', | |
'attr' => '', | |
) ); | |
printf( '<figure class="featured-image-class aligncenter">%s%s</figure>', $image, $caption ); | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment