Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Autoload Slider Lightbox Gallery

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

Note: This document is relevant only if you have a Developer or Master license and you’re using the Lightbox Addon.

It may be that you want to automatically fire the lightbox from the Lightbox Addon when you visit a page. This is pretty simple and just requires a little bit a JS magic to get it working.

Basically we find the first link item that has the “soliloquybox” rel attribute that is not a cloned image (cloned images are used in sliding transitions) and force the click event to fire, opening up the lightbox.

Add the following code to your active theme’s functions.php file, change the slider number to the unique slider that you want to target:

add_action( 'soliloquy_api_on_load', 'tgm_soliloquy_auto_lightbox' );
function tgm_soliloquy_auto_lightbox( $data ) {

	// If the slider slug does not match the slider we want to target, bail. Change the number to your particular slider.
        if ( $data['config']['slug'] != 'my-slug' ){
             return;
 	}

	// Trigger the click event to open up the lightbox with a slight delay (500ms).
	$find = ".soliloquy-item:not(.clone) a[rel^='soliloquybox']";
	echo 'setTimeout(function(){$("#soliloquy-container-' . absint( $data['id'] ) . '").find("' . $find . '").first().trigger("click");}, 300);';

}

Note: If you want to apply this filter to all sliders instead of targeting them individually by ID, simply edit the example code to remove lines 4-6.

[i]
[i]