Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Disable Sliders on Mobile Devices

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

You can disable all Soliloquy sliders on mobile devices (therefore preventing any Soliloquy resources from loading on mobile devices) following this guide.

Step 1 – Create Plugin File

The first step is to create a new php file in the wp-content/plugins/ directory of your WordPress installation. The easiest way to do this is using your favorite FTP program or through your web hosting account’s file editor (if they provide one).

Once you’ve navigated to the wp-content/plugins/ directory, create a new file with the name soliloquy-disable-mobile.php

Step 2 – Edit the New Plugin File

Next, you’ll want to copy and paste the following code into the soliloquy-disable-mobile.php plugin file you’ve created:

<?php
/**
* Plugin Name: Soliloquy - Disable on Mobile
* Plugin URI: https://soliloquywp.com
* Version: 1.0
* Author: Tim Carr
* Author URI: http://www.n7studios.co.uk
* Description: Completely disable loading of any Soliloquy sliders on mobile devices
*/

/**
* Check if user is on a mobile device, and if so don't return any data
*
* @param array $data Slider Data
* @param int $slider_id Slider ID
* @return array Slider Data
*/
function sol_soliloquy_disable_mobile( $data, $slider_id ) {
	
	// If on a mobile device, empty $data so that shortcode returns nothing
	// This also means no scripts will load
	if ( wp_is_mobile() ) {
		return false;
	}
	
	return $data;
	
}
add_filter( 'soliloquy_pre_data', 'sol_soliloquy_disable_mobile', 10, 2 );

Step 3 – Activate the New Plugin

The last step is to navigate to the WordPress Admin > Plugins screen, locate the plugin named Soliloquy – Disable on Mobile and activate the plugin.

That’s it! Your sliders will now load only on non-mobile devices!

[i]
[i]