• Hello,

    I am in a big problem (at least that’s the way I see it). I’ve tried plenty of times to move WordPress to wp_head() instead of wp_footer(), but it simply doesn’t work. When I try to add a script to wp_head(), it doesn’t show up either. Here is the code I used in theme’s function.php:

    if (!is_admin()) add_action("wp_enqueue_scripts", "jquery_to_top");
    function jquery_to_top() {
       wp_deregister_script('jquery');
       wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js", false, null, false);
       wp_enqueue_script('jquery');
    }

    So based on the Codex, this should the jQuery script to wp_head(). But it doesn’t.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Looks like your syntax is off. I believe it should be something more like this:

    function jquery_to_top() {
    if ( !is_admin() ) {
    add_action("wp_enqueue_scripts", "jquery_to_top");
    wp_deregister_script('jquery');
    wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js", false, null, false);
       wp_enqueue_script('jquery');
    }
    }

    Also, you might checkout this resource:
    https://stackoverflow.com/questions/4927352/adding-a-jquery-script-to-wordpress-admin

    We do this all the time at LabZip and 1WD tv so if you need any other help, just drop me a line ??

    Cheers!
    spence

    Upon reflection.. actually, probably more like this:

    if ( !is_admin() ) {
    add_action("wp_enqueue_scripts", "jquery_to_top");
    }
    
    function jquery_to_top() {
    wp_deregister_script('jquery');
    wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js", false, null, false);
       wp_enqueue_script('jquery');
    }
    Thread Starter kiscoeteam

    (@kiscoeteam)

    Still doesn’t work with any of them. Any ideas?

    Not knowing where or what you are trying to do with this… or what you have installed with other plugins or themes (that may be causing a conflict), the only other suggestion I have is to add a priority to the action (11), and see if this works. I’ve reverted back to the original action syntax as well.

    if (!is_admin()) add_action("wp_enqueue_scripts", "jquery_to_top", 11);
    function jquery_to_top() {
    wp_deregister_script('jquery');
    wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
    wp_enqueue_script('jquery');
    }
    Thread Starter kiscoeteam

    (@kiscoeteam)

    Already tried that. Basically, I have a theme (typegrid11) and I want to move the jQuery script (which at the moment is in footer) in the header. I tried everything but it simply doesn’t work. However, if I use the above function for example to change the jQuery source path, it works, I see the changes. It just won’t put it in the header.

    Where did you download this theme from?

    Thread Starter kiscoeteam

    (@kiscoeteam)

    It’s a paid one from ThemeForest.

    I’m sorry but as you are using a commercial theme, you need to seek support from the theme’s developer/vendor. We do not support commercial products here.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘jQuery to header’ is closed to new replies.