How do I pass $in_foooter to wp_enqueue_script() without passing other params?

Try passing array() for $deps, and NULL for $ver: wp_enqueue_script( $handle, $src, array(), NULL, $in_footer); Or, using your function call: wp_enqueue_script(“myscript” , get_template_directory_uri().”/js/myscript.js”, array(), NULL, true ); By the way, passing the script itself as a dependency to itself will probably make something blow up. Note also: if your script depends on jQuery, just pass … Read more

Why is this function crashing my wordpress installation? [closed]

First, be sure to enable WP_DEBUG in your wp-config.php file, so that you can see fatal error messages. In this case, the problem is that you’ve named your function load_wforms(), but you reference the callback wforms in your add_action() call: function load_wforms() {} …vs… add_action(‘init’, ‘wforms’); The second parameter, wforms, refers to a function named … Read more

Failing to load my script files in wordpress! i can’t figure out what i’m doing wrong

Probable Cause I strongly suspect that you do not call wp_head() in your header.php file, immediately before the closing HTML </head> tag: <?php wp_head(); ?> </head> You must call this template tag, in order to fire the wp_head action. The wp_head action in turn fires the wp_enqueue_scripts action. So, without having <?php wp_head(); ?> in … Read more

force jQuery to load in the head

Edit: new solution, based on one of the comments. If you are using wp_enqueue_script to load your js file, make sure jQuery is a dependency so that it gets called before your code: wp_enqueue_script( ‘my_script’, ‘my-script.js’, array( ‘jquery’), $ver, true ); You can then remove the original enqueue call you had since jQuery will be … Read more

Enqueueing scripts selectively & activation where needed

If you’re only enqueueing scripts when they’re needed, you can check in JS if the plugin’s namespace exists before trying to use it: if( $.fn.slider ) { $(‘#slider’).slider(); } or another option is to pass some script vars via wp_localize_script: $wpa_script_data = array( ‘is_front_page’ => is_front_page(), ‘slider_options’ => array( ‘speed’ => 6000 ) ); wp_localize_script( … Read more

enqueue_script doesn’t work with HTML5 blank theme

I’m not sure but it might have something to do with the html5blank_protocol_relative() function used by HTML5 Blank Theme. You could try removing the filters at L# 382 & 383 of the functions.php file. // Protocol relative URLs for enqueued scripts add_filter( ‘script_loader_src’, ‘html5blank_protocol_relative’ ); // Protocol relative URLs for enqueued styles add_filter( ‘style_loader_src’ , … Read more