Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a piece of PHP code that's supposed to load 3 jquery files. For some reason, I can only see 2 of them in the source. I can't figure out why - can anyone help me please?

Website: www.goinspire.com

My code:

add_action( 'wp_print_scripts', 'add_my_jquery', 1 );

function add_my_jquery(){
 //Custom function to load a jquery script called smoothscroll.js that puts a smoothscroll on our site

wp_enqueue_script( 'smoothup', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), '',  true );

//end

/*This part is to move the Subscribe button above the Submit button */
wp_enqueue_script( 'submitbutton', get_template_directory_uri() . '/js/submitbutton.js', array( 'jquery' ), '',  true );

//include jqueryfunctions.js, for some functions (including hotel landing page filters)
wp_enqueue_script('jqueryfunctions', get_template_directory_uri() . '/js/jqueryfunctions.js', array('jquery'), '', true);
}

Thanks in advance!

Update: the one that doesn't load is jqueryfunctions.js.

Thanks!

Updated code:

 add_filter( 'image_size_names_choose', 'custom_in_post_images' );

//END

add_action( 'wp_enqueue_scripts', 'add_my_jquery', 1 );

function add_my_jquery(){
 //Custom function to load a jquery script called smoothscroll.js that puts a smoothscroll on our site

wp_enqueue_script( 'smoothup', get_template_directory_uri() . '/js/smoothscroll.js', array( 'jquery' ), '',  true );

//end

/*This part is to move the Subscribe button above the Submit button */
wp_enqueue_script( 'submitbutton', get_template_directory_uri() . '/js/submitbutton.js', array( 'jquery' ), '',  true );

//include jqueryfunctions.js, for some functions (including hotel landing page filters)
wp_enqueue_script('customjqueryfunctions', get_template_directory_uri() . '/js/customjqueryfunctions.js', array( ), '', true);
}
share|improve this question
1  
You should not be hooking into wp_print_scripts. Use wp_enqueue_scripts. Which script doesn't load? –  s_ha_dum Feb 24 at 20:28
    
I made that change, but it still doesn't load. The problematic one is jqueryfunctions.js –  user3515 Feb 24 at 20:58
    
Try changing the name to something more unique than jqueryfunctions - also you could try to pass a blank array instead of jquery, since jquery should already be loaded with the previous scripts. Not 100% sure, the script is in the right place and everything looks correct. –  Howdy_McGee Feb 25 at 17:57
    
I made those 2 changes, and still no success. See my updated code above. Thanks! –  user3515 Feb 25 at 18:16
    
It's probably for the best that it's not loading. The code has a couple of serious issues, like triggering a print when the page is loaded, and trying to parse PHP inside the external JS file. Even if the script did load, it'd cause problems for you. –  morganestes Feb 27 at 5:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.