0

I'm trying to add multiple scripts and style on my custom theme option via functions.php, I declare it like this

function cyb_admin_scripts() {
    wp_enqueue_script('my-script',get_template_directory_uri().'/theme-options/jquery.js');
    //Enqueue styles and scripts
    wp_enqueue_script('my-script',get_template_directory_uri().'/theme-options/script.js', array('jquery'));
    wp_enqueue_style('my-style',get_template_directory_uri().'/theme-options/style.css');
}
add_action('admin_enqueue_scripts', 'cyb_admin_scripts');

but unfortunately only one is added like jquery only. Any help, suggestions, clues, recommendation please?

Juliver Galleto
  • 8,831
  • 27
  • 86
  • 164
  • Possible duplicate of [Javascript: How to use a regular expression to remove blank lines from a string?](http://stackoverflow.com/questions/16369642/javascript-how-to-use-a-regular-expression-to-remove-blank-lines-from-a-string) – rrk Jan 20 '16 at 04:19
  • check `console` for errors and try to fix those. – Gautam Jha Jan 20 '16 at 04:47

1 Answers1

0

When you are loading scripts using wp_enqueue_script, first parameter must be your unique name for handle this script later, if needed. In your case you are using name 'my-script' twice. I never did this, but suppose, that one script overwrites other in some point.

So try to use unique names for all your scripts and styles.

wp_enqueue_script

Also in your script.js you use jquery as dependance, but this will load jquery library that comes with WP, so you don't need to include your own jquery from theme-options folder

pgk
  • 1,437
  • 1
  • 21
  • 20