Skip to content

Show captions under thumbnails and single images

This article may be outdated and referencing Sunshine Photo Cart 2. Documentation articles are currently being updated and hope to be fully accurate very soon. Apologies for any confusion.

For custom code like the samples below, it is recommended to add it with a plugin like Code Snippets so as not to edit any important core files in WordPress, Sunshine Photo Cart, or your theme.

Show caption with thumbnails

Sunshine has an option to show theĀ image name under the thumbnails in the Gallery view. In Galleries > Settings > Galleries > Show Image Data, select “Filename” or “Title”.

The following code uses the “sunshine_image_name” filter and if a caption exists it replaces the default display to be displayed with the caption.

// 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->get_data_value( 'post_excerpt' ) ) ) {
		$caption = $image->get_data_value( 'post_excerpt' );
	return $caption;

Show caption under single image view

Each image in your gallery has it’s own URL with the image displayed and various options. You can include the caption on this page below the image with the following custom code:

// Show caption on single image page
add_filter( 'sunshine_after_image', 'sunshine_image_show_caption', 10 );
function sunshine_image_show_caption( $image ) {
	if ( ! empty( $image->get_data_value( 'post_excerpt' ) ) ) {
		echo $image->get_data_value( 'post_excerpt' );

Still need help?

If you have not yet found your answer in the documentation articles, please contact support