Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Automatically Wrap Caption Text in Paragraph Tags

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

If you plan to wrap all of your caption text in paragraph tags, you can save yourself some time and use the following filter to automatically wrap new lines of text entered in the Caption field with paragraph tags.

Add the following code to your active theme’s functions.php file:

add_filter( 'soliloquy_output_item_data', 'ekf_filter_caption_paragraph_tags', 10, 3 );
function ekf_filter_caption_paragraph_tags( $image, $id, $data) {
	// Wrap the image caption text in paragraph tags
        $image['caption'] = wpautop( $image['caption'] );
	// Return the modified data.
	return $image;