Created
December 5, 2015 15:40
-
-
Save uncatcrea/ecf641281eea35ecfb88 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
//In your theme's php folder for example: | |
add_filter( 'wpak_post_data', 'wpak_add_thumbnail_caption', 10, 3 ); | |
function wpak_add_thumbnail_caption( $post_data, $post, $component ) { | |
$thumbnail_id = get_post_thumbnail_id( $post->ID ); | |
if ( $thumbnail_id ) { | |
$image_post = get_post( $thumbnail_id ); | |
if ( $image_post ) { | |
if ( !empty( $post_data['thumbnail'] ) ) { | |
$post_data['thumbnail']['caption'] = $image_post->post_excerpt; | |
} | |
} | |
} | |
return $post_data; | |
} | |
//Then you can use post.thumbnail.caption in single.html and archive.html templates. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment