Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Set a Default Caption

Important: This doc assumes you’re comfortable creating and/or editing PHP files in your WordPress installation and is intended for advanced users.

You may want to set a default caption in the event that all your images have the same caption. In this example, if no custom caption is entered, it will default to the image title. This can be modified to anything you require.

Add the following code to your active theme’s style.css file and adjust as you require:

add_filter( 'soliloquy_output_item_data', 'tgm_filter_caption_to_image_title', 10, 3 );
function tgm_filter_caption_to_image_title( $image, $id, $data) {
	
	// Fallback to image title if no caption is set.
        if ( 'image' == $image['type'] ) {
	        $image['caption'] = ! empty( $image['caption'] ) ? $image['caption'] : $image['title'];
        }
	
	// Return the modified data.
	return $image;
	
}
[i]
[i]