Title: Customize javascript settings via admin?
Last modified: August 22, 2016

---

# Customize javascript settings via admin?

 *  [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/customize-javascript-settings-via-admin/)
 * My assumption is that I’m dealing with customizer stuff, and variable passing,
   but I’ve searched for different combinations and haven’t had luck finding the
   right info.
 * Here’s what I’d like to accomplish:
 * I have a simple slideshow set up using Advanced Custom Fields to get the images&
   captions. I have a JS file that injects settings (transition time, etc.) into
   the main slider script. I’d like to add a way to change the slider settings via
   the admin. Much like you can change site title & description in the customizer.
 * Not looking for a total solution, just a point in the right general direction
   in the Codex maybe. Not sure where to start.
 * Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/customize-javascript-settings-via-admin/#post-5913271)
 * OK, I’ve figured out most of this. I think the rest of my solution is to involve
   the ACF variables. I’ll add more info if I resolve it, maybe this will help someone
   else searching for similar info.
 *     ```
       // in functions.php
   
       	// enqueue my script (and the settings script)
       	wp_enqueue_script( 'my-slider', get_template_directory_uri() . '/js/responsiveslides.js', array(), '20150311', true );
       	wp_enqueue_script( 'my-slider-settings', get_template_directory_uri() . '/js/responsiveslides-settings.js', array('my-slider'), '20150311', true );
   
       	// localize my settings script to pass variables into PHP
       	$params = array(
       	    'auto' => true,
       	    'speed' => 500,
       	    'timeout' => 1000
       	);
       	wp_localize_script( 'my-slider-settings', 'mysliderparams', $params );
   
       	// And in responsiveslides-settings.js
   
       	(function($){
   
       	    $("#slider").responsiveSlides({
       	      auto: mysliderparams.auto,
       	      speed: mysliderparams.speed,
       	      timeout: mysliderparams.timeout
       	    });
   
       	})(jQuery);
       ```
   
 *  Thread Starter [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * (@elmnt)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/customize-javascript-settings-via-admin/#post-5913288)
 * I was able to get it working with this one modification:
 *     ```
       $timeoutvar = get_field('slideshow_timeout');
   
       	$params = array(
       	    'auto' => true,
       	    'speed' => 500,
       	    'timeout' => $timeoutvar
       	);
       ```
   
 * I just access my ACF name and set it as a variable.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Customize javascript settings via admin?’ is closed to new replies.

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 1 participant
 * Last reply from: [Greg Smith](https://wordpress.org/support/users/elmnt/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/customize-javascript-settings-via-admin/#post-5913288)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
