I'm building a Wordpress theme using Twitter Bootstrap.

I have registered and enqueued the bootstrap .js file (including others) and everything works fine. This is my code:

wp_register_script( 'wp-flat-bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );

However, I have just integrated the Flexslider by WooThemes and I have also registered and enqueued its .js file. This is my code:

wp_register_script( 'flexslider-jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', '', true );

Whenever, I land on the page where the Flexslider appears the bootstrap .js's file stops working, which has its effect in that the menubar drop down stops working.

Does anybody know how I can use the two scripts together without having this issue?

  • 1
    Only ever use the core-bundled version of jQuery. WordPress currently uses jQuery 1.10.x. Loading jQuery 1.6.2 on top of that is going to break things. – Chip Bennett Apr 29 '14 at 12:35

The code you wrote is NOT including the flexslider code, it is only trying to include a google hosted copy of jquery.

wp_register_script( 'flexslider-jquery',
  # this is just the Google Hosted version of jQuery
  '', true );

You probably want something more like this:

wp_register_script( 'flexslider-jquery',
  get_template_directory_uri() . '/js/jquery.flexslider-min.js',
  array( 'jquery' ), false, true );

You'll need to put the flexslider code in the right directory of course, or adjust the above to match your site structure.

  • Sorry, I should have included that I use both: wp_register_script( 'flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'), '', true ); and wp_register_script( 'flexslider-jquery', 'ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', '', true ); – user50763 Apr 30 '14 at 13:00
  • As mentioned by Chip in the comments above, you don't need to include the second jQuery. If you believe you absolutely must, then you must also deregister the old jQuery before adding the next to prevent conflicts. If you are intentionally trying to run two versions of jQuery, then you probably have them setup correctly in no-conflict mode and unique variables assigned to each instance and you will, at least, need to make sure your flexslider script registration is using the correct dependency chain wp_register_script( 'flexslider', '...', array( 'flexslider-jquery', '', true ); – totels May 7 '14 at 10:23
  • P.S. Are you enqueuing wp_enqueue_script( 'flexslider' ) your flexslider somewhere else, if not, it won't be output, check your source output to see if the script tags are there. – totels May 7 '14 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.