Skip to content

Instantly share code, notes, and snippets.

@sunshinephotocart
Last active January 29, 2019 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunshinephotocart/9a761ed1e5ad57e9ae7456b257584f03 to your computer and use it in GitHub Desktop.
Save sunshinephotocart/9a761ed1e5ad57e9ae7456b257584f03 to your computer and use it in GitHub Desktop.
Show caption name
// Add this to your theme's functions.php file
// Or use this plugin https://wordpress.org/plugins/my-custom-functions/
// Show caption under thumbnail
add_filter( 'sunshine_image_name', 'sunshine_thumbnail_show_caption', 10, 2 );
function sunshine_thumbnail_show_caption( $caption, $image ) {
if ( !empty( $image->post_excerpt ) ) {
$caption = $image->post_excerpt;
}
return $caption;
}
// Show caption on single image page
add_filter( 'sunshine_after_image', 'sunshine_image_show_caption', 10 );
function sunshine_image_show_caption( $image_id ) {
$image = get_post( $image_id );
if ( !empty( $image->post_excerpt ) ) {
echo $image->post_excerpt;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment