Much like any WordPress themes, Genesis themes allow users to display a caption under their images when they are use in side the article. However, if you want to display a caption on a featured image, you need to use custom code snippet inside your theme functions.
A caption on a featured image can be useful for reasons — display copyright info, mention the source of your image, add meaning to your featured image for storytelling etc. The point being displaying caption in featured image should be a default feature in WordPress themes (and Genesis Themes) considering its importance and use cases.
Working on a recent project and hunting for this solution led me to Genesis Facebook Group, and invariably, Sridhar came to my rescue. Indeed, the man has a HUGE heart. 🙂
If you want to learn how to use a caption on featured image in Genesis, follow along.
Step #1: Display Featured Image with Caption in Genesis (add code to functions.php)
Step #2: Style Featured Image Caption in Genesis (add code to style.css)
Step #3: Enable Font Awesome on your theme (optional – required in the above css code)
That’s it – go creative and add a meaningful caption to your featured image.
Please, let me know if you have any questions.
Avinash says
A tad late, but what would be the code to add ONLY the caption to an existing featured image?
topleague says
Unable to understand your question. Can you be a bit more elaborative!
mo. says
Try this:
/* Code to Display Featured Image on top of the post */
add_action( 'genesis_before_entry', 'featured_post_image', 8 );
function featured_post_image() {
if ( ! is_singular( 'post' ) ) return;
$image = genesis_get_image( 'format=url&size=post-image' ); // get the URL of featured image.
$thumb_id = get_post_thumbnail_id( get_the_ID() ); // get the alt text of featured image.
$alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true );
$caption = get_post( $thumb_id )->post_excerpt; // get the caption of featured image.
$caption_html = $caption ? ''. $caption . '' : ''; // Construct the caption HTML if caption is present for the featured image..
printf( '%s', esc_url( $image ), $alt, $caption_html ); // display the featured image with caption (if present) beneath the image.
}
</codes