Soliloquy Documentation
Documentation, Reference Materials, and Tutorials for Soliloquy
Documentation, Reference Materials, and Tutorials for Soliloquy
Would you like your slider to have a default caption when no caption exists? Soliloquy can easily help you set the image title to the caption when a caption hasn’t been entered. We’ll walk you through how to set a default caption.
Note: This tutorial is a bit more technical than our other docs, but we’ll walk you through the process step by step. In order to set a default caption, we’ll need to create and upload a basic WordPress plugin.
To set the image title as a fallback for your captions, just add the following code to a new file at wp-content/plugins/soliloquy-defualt-caption-image-title.php
.
/**
* Plugin Name: Soliloquy – Default Caption
* Plugin URI: https://soliloquywp.com
* Description: Plugin that set the image title as the caption when no caption exists
* Author: Soliloquy Team
* Author URI: https://soliloquywp.com
* Version: 1.0
* Domain Path: languages
*/
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;
}[/php]
If you’re unsure how to create a plugin file, follow these steps below:
soliloquy-defualt-caption-image-title.php
Your next step is to activate the plugin you just uploaded. Simply navigate to the Plugins from within your WordPress dashboard and activate the Soliloquy – Default Caption plugin.
That’s it! You’ve set the image title as a default caption for all slider iamges. Would you like to extend Soliloquy further? Take a look at our tutorial on How to White Label Soliloquy.