Support » Fixing WordPress » Unable to enqueue jQuery

  • Resolved CGAdmin


    For one reason or another, I am unable to get my script to properly enqueue even though it works (nearly) perfectly embedded in the footer. The script is to allow for the overlapping/hiding of multiple pages on a small user login form on the header. I have attempted various versions of the following enqueue function:

    function my_scripts_method() {
    	get_template_directory_uri() . '/js/login.js',
    	wp_enqueue_script('login_script'); }
    add_action('wp_enqueue_scripts', 'my_scripts_method');

    The login.js file is as follows:

    jQuery(document).ready(function() {
    	jQuery("ul.tabs_login li:first").addClass("active_login").show();
    	jQuery("ul.tabs_login li").click(function() {
    		jQuery("ul.tabs_login li").removeClass("active_login");
    		var activeTab = jQuery(this).find("a").attr("href");
    		if (jQuery.browser.msie) {jQuery(activeTab).show();}
    		else {jQuery(activeTab).show();}
    		return false;

    As I mentioned, I am able to embed this same code in no conflict mode directly in the footer, but I would prefer to be able to keep these files as clean as possible.

    Am I performing the enqueue function incorrectly?

Viewing 1 replies (of 1 total)
  • CGAdmin


    I just got to thinking, the enqueue function references a JS file located at “/js/login.js”. We are creating a multisite network and have been doing much of the testing on one of the “child” sites. This means the function was looking in the wrong directory for the JS file since the architecture is set up as and the JS file is located at

    For those with the same stupid hat on as me, be sure to include a “../” in front of url references when working with multisite installations! (Otherwise, the code is just fine.)

    New line in function should be:

    get_template_directory_uri() . '../js/login.js',

Viewing 1 replies (of 1 total)
  • The topic ‘Unable to enqueue jQuery’ is closed to new replies.