Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Sliders Based on Day of the Week

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

Just had a support ticket asking how someone could display a different image for each day of the week. I thought up an easy solution that gives you complete control over what slider appears each day.

Step 1 – Create Daily Sliders

First, you’ll create 7 sliders: one for each day of the week. This gives you complete control over what is displayed each day.

Step 2 – Conditionally Display Sliders

Next, we conditionally display the proper slider based on the server time given to us.

You’ll use the following code in conjunction with your theme either via template files or a hook.

if ( function_exists( 'soliloquy' ) ) {
 	$sliders = array(
 		'YOUR_SLIDER_SLUG_HERE', // Tuesday
 		'YOUR_SLIDER_SLUG_HERE', // Wednesday
 		'YOUR_SLIDER_SLUG_HERE', // Thursday
 		'YOUR_SLIDER_SLUG_HERE', // Saturday
    soliloquy( $sliders[date( 'w', time() )], 'slug' );