Created
October 12, 2017 12:53
-
-
Save carasmo/819ff7b8d6057bbcfb8541e6d830a6ff to your computer and use it in GitHub Desktop.
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 COPY THIS opening tag into your file. Use a code editor and ftp. | |
add_action( 'genesis_entry_content', 'yourprefix_display_featured_image', 5 ); | |
/** | |
* Show Featured Image Posts | |
* @since 1.0.0 | |
*/ | |
function yourprefix_display_featured_image() { | |
if ( ! has_post_thumbnail() || ! is_singular( 'post' ) ) return; | |
$caption = ''; | |
$caption = get_post( get_post_thumbnail_id() )->post_excerpt; | |
if ( ! empty( $caption ) ) : | |
$caption = sprintf( '<figcaption>%s</figcaption>', $caption ); | |
endif; | |
$image = genesis_get_image( array( | |
'format' => 'html', | |
'size' => 'your-featured-image-size', //change between the ticks to your featured image size | |
'context' => '', | |
'attr' => '', | |
) ); | |
printf( '<figure class="featured-image aligncenter">%s%s</figure>', $image, $caption ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment