Soliloquy Documentation

Documentation, Reference Materials, and Tutorials for Soliloquy

Disable Sliders on Mobile Devices

Would you like to disable sliders on mobile devices? This can be done by creating a custom plugin. We’ll walk you through each step on disabling the sliders on mobile devices.

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 disable the sliders on mobile, we’ll need to create and upload a basic WordPress plugin.


Creating the Plugin

To disable sliders on mobile, just add the following code to a new file at wp-content/plugins/soliloquy-disable-slider-mobile.php.

[php]<?php
/**
* Plugin Name: Soliloquy – Disable on Mobile
* Plugin URI: https://soliloquywp.com
* Version: 1.0
* Author: Soliloquy Team
* Author URI: https://soliloquywp.com
* Description: Completely disable loading of any Soliloquy sliders on mobile devices
*/

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 );[/php]

If you’re unsure how to create a plugin file, follow these steps below:

  1. Open a text file and make sure that it is a plain text document. You can use a plain text editor like Notepad or a code editor of your choice.
  2. Next, copy and paste the code shown above into the file and save the file as soliloquy-disable-slider-mobile.php
  3. Once you’ve saved the file you can easily upload this directly to your /plugins directory on your server using FTP or you can right-click on the text document and zip (or compress).
  4. Finally, log in to your WordPress dashboard and go to Plugins » Add New » Upload Plugin and upload the .zip file you just created in the previous step.

Activate the Plugin

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 – Disable on Mobile plugin.

To disable the sliders on mobile, activate the custom plugin

And that’s it! You’ve now disabled your sliders on mobile devices!

Would you like to add a slide counter to your sliders? Have a look at our article on How to Add Slide Count to a Slider.