Problem with wp_enqueue_script('jquery') (3 posts)

  1. BFreitag04
    Posted 3 years ago #

    Hey, I've been trying to get this plugin to work right. It does what it should in Chrome, but in FireFox and IE it does not work.

    Basically where FF and IE and messing up is with the wp_enqueue_script('jquery') function.

    function load_scripts()
    add_action('init', 'load_scripts');

    I have also tried to use add_action('wp_enqueue_scripts', 'load_scripts'); And that did not work either.

    Why is it that jQuery is not being loaded according to FF and IE?.

    Should I being doing something different to load it?
    Any input would be greatly appreciated, thanks.

  2. Sunny_Balanga
    Posted 3 years ago #

    I'm working on my first plugin and here's what's working for me:

    Create a function to both register AND enqueue the script and then add_action to call the function (the !is_admin condition is to avoid loading the script while in the admin panel if it's not needed there )

    function load_scripts() {
    	if (!is_admin()){
    		wp_register_script( 'my_script', plugins_url( '/jquery.js', __FILE__ ));
    		wp_enqueue_script( 'my_script' );
    add_action('wp_enqueue_scripts', 'load_scripts');
  3. BFreitag04
    Posted 3 years ago #

    The only thing about that though is they do not want us to use our own jQuery file, they are wanting us to use the one that is prepackaged with WordPress.

    How I have it works in Chrome but not FF or IE, so I'm just curious as to the reason.

    In the codex it shows that the handle for their jQuery file is just 'jquery', so one should be able to use 'wp_enqueue_script('jquery').'

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.