Last updated on October 18, 2023

Divi slider not working

Don’t know where to add this snippet? Read our guide: How to add code snippets.

Fix Divi slider issues with our code.

The Divi theme is a popular WordPress theme that includes a built-in slider module. However, there may be instances where the Divi slider is not working as expected. This can be due to various reasons such as conflicts with other plugins or themes, JavaScript errors, or incorrect settings.

To troubleshoot and fix the Divi slider not working issue, you can follow these steps:

  1. Check for JavaScript errors: Open your website in a browser and open the browser’s developer console (usually accessible by right-clicking and selecting “Inspect” or “Inspect Element”). Look for any JavaScript errors that may be causing the slider to malfunction. Resolve these errors by fixing the code or disabling conflicting plugins.

  2. Disable conflicting plugins: Temporarily deactivate all other plugins except for Divi and see if the slider starts working. If it does, then one of the deactivated plugins is causing a conflict. Activate each plugin one by one to identify the conflicting plugin and either find an alternative or contact the plugin developer for support.

  3. Switch to a default theme: Temporarily switch to a default WordPress theme like Twenty Twenty-One and check if the slider works. If it does, then the issue may be with your current theme. You can reach out to the theme developer for assistance or consider using a different theme.

  4. Clear cache: If you are using a caching plugin or a CDN, clear the cache to ensure that you are seeing the latest version of your website. Sometimes, outdated cached files can cause issues with the slider.

  5. Update Divi theme: Ensure that you are using the latest version of the Divi theme. Updates often include bug fixes and improvements that can resolve issues with the slider.

If none of the above steps resolve the issue, you can try adding custom CSS or JavaScript code to fix any specific problems with the slider. Here’s an example of custom CSS code that can be added to the Divi theme’s “Customizer” or “Theme Options” section:

/* Example CSS code to fix Divi slider height */
.et_pb_slider .et_pb_slide {
    min-height: 400px;
}

This code sets a minimum height of 400 pixels for each slide in the Divi slider. Adjust the value as needed to fit your design requirements.

Remember to always test your changes on a staging or development site before applying them to a live site.

Examples

Example 1: Troubleshooting Divi Slider Not Working

This example demonstrates how to troubleshoot and fix issues with the Divi slider not working on a WordPress website.

function wpsnippets_fix_divi_slider() {
    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'et-jquery-touch-mobile', get_template_directory_uri() . '/js/jquery.mobile.custom.min.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-waypoints', get_template_directory_uri() . '/js/jquery.waypoints.min.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-jquery-waypoints', get_template_directory_uri() . '/js/jquery.waypoints.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-jquery-migrate-waypoints', get_template_directory_uri() . '/js/jquery.migrate.waypoints.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-jquery-sticky', get_template_directory_uri() . '/js/jquery.sticky.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-jquery-parallax', get_template_directory_uri() . '/js/jquery.parallax.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-jquery-migrate-parallax', get_template_directory_uri() . '/js/jquery.migrate.parallax.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-jquery-smooth-scroll', get_template_directory_uri() . '/js/jquery.smooth-scroll.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-jquery-easing', get_template_directory_uri() . '/js/jquery.easing.js', array( 'jquery' ), false, true );
    wp_enqueue_script( 'et-divi-custom-script', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), false, true );
}
add_action( 'wp_enqueue_scripts', 'wpsnippets_fix_divi_slider' );

The code example above fixes the issue of the Divi slider not working by enqueuing the necessary JavaScript files required by the Divi theme. It uses the wp_enqueue_script() function to load the scripts in the correct order and with the correct dependencies. By adding this code to the theme’s functions.php file, the Divi slider should start working properly.

Example 2: Checking for JavaScript Conflicts

This example demonstrates how to check for JavaScript conflicts that may be causing the Divi slider to not work.

function wpsnippets_check_js_conflicts() {
    if ( is_page_template( 'page-template.php' ) ) {
        wp_dequeue_script( 'jquery' );
        wp_deregister_script( 'jquery' );
        wp_enqueue_script( 'jquery', 'https://code.jquery.com/jquery-3.6.0.min.js', array(), '3.6.0', true );
    }
}
add_action( 'wp_enqueue_scripts', 'wpsnippets_check_js_conflicts', 9999 );

The code example above checks if the current page is using a specific page template (page-template.php) and if so, it dequeues and deregisters the default WordPress jQuery script. It then enqueues a different version of jQuery from a remote source. This can help identify and resolve conflicts between different versions of jQuery that may be causing the Divi slider to not work.

Example 3: Clearing Cache and Refreshing Scripts

This example demonstrates how to clear cache and force a refresh of the scripts to resolve any caching-related issues that may be causing the Divi slider to not work.

function wpsnippets_clear_cache_refresh_scripts() {
    if ( is_page( 'my-slider-page' ) ) {
        wp_enqueue_script( 'et-divi-custom-script', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), false, true );
        wp_dequeue_script( 'et-divi-custom-script' );
        wp_enqueue_script( 'et-divi-custom-script', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), false, true );
    }
}
add_action( 'wp_enqueue_scripts', 'wpsnippets_clear_cache_refresh_scripts', 9999 );

The code example above clears the cache and refreshes the scripts by dequeuing and enqueuing the Divi custom script again. It specifically targets a page with the slug my-slider-page using the is_page() function. By doing this, any cached versions of the script will be cleared, and a fresh version will be loaded, potentially resolving any caching-related issues that may be causing the Divi slider to not work.

Last updated on October 18, 2023. Originally posted on October 23, 2023.

Leave a Reply