How do I make script load after jquery?

You have a typo in your code. It should be: function load_my_script(){ wp_register_script( ‘my_script’, get_template_directory_uri() . ‘/js/myscript.js’, array( ‘jquery’ ) ); wp_enqueue_script( ‘my_script’ ); } add_action(‘wp_enqueue_scripts’, ‘load_my_script’); The jQuery dependency needs to be an array(), not just a string. This will force your script to load after jQuery.

Register a script to be enqueued both in admin and front end

You can register the scripts earlier, for example on wp_loaded: add_action( ‘wp_loaded’, ‘register_all_scripts’ ); function register_all_scripts() { wp_register_script(…); } And then you enqueue the scripts whenever you need them: add_action( ‘wp_enqueue_scripts’, ‘enqueue_front_scripts’ ); add_action( ‘admin_enqueue_scripts’, ‘enqueue_back_scripts’ ); Use the same handles and names to avoid collisions with other scripts.

How to include jQuery and JavaScript files correctly?

First rule of thumb: do not deregister core-bundled scripts and replace with other versions, unless you are absolutely certain that no Theme, Plugins, or core itself will break due to the version change. Really, unless you absolutely need an alternate version of a core-bundled script, just use what is bundled with core. Second, I strongly … Read more

Prevent Version URL Parameter (?ver=X.X.X) on Enqueued Styles & Scripts

Default wp_enqueue_[style/script]() behavior The default value for the $version argument of wp_enqueue_style() is false. However, that default just means that the stylesheets are given the WordPress version instead. Solution Thanks to “Remove version from WordPress enqueued CSS and JS”, I learned the undocumented fact that passing in null as a version will remove the version … Read more

How to properly dequeue scripts and styles in child theme?

You are very nearer to the solution, because you are on the right path. Just to tweak a little bit: There are two such action hooks: wp_print_scripts, and wp_print_styles So the way you can do it, is: hook ’em differently: //Dequeue Styles function project_dequeue_unnecessary_styles() { wp_dequeue_style( ‘bootstrap-map’ ); wp_deregister_style( ‘bootstrap-map’ ); } add_action( ‘wp_print_styles’, ‘project_dequeue_unnecessary_styles’ … Read more

How to enqueue JavaScripts in a plugin

Your code seems correct, but it will load the script only in admin area beacuse you are enqueuing the script in admin_enqueue_scripts action. To load the script in frontend, use wp_enqueue_scripts action (which is not the same that wp_enqueue_script() function): function Zumper_widget_enqueue_script() { wp_enqueue_script( ‘my_custom_script’, plugin_dir_url( __FILE__ ) . ‘js/jquery.repeatable.js’ ); } add_action(‘wp_enqueue_scripts’, ‘Zumper_widget_enqueue_script’); Also, … Read more

How can I get a list of all enqueued scripts and styles?

do_action doesn’t quite work like that. When you call do_action(‘crunchify_print_scripts_styles’) WP looks at its list of registered actions and filters for any that are attached to a hook called crunchify_print_scripts_styles and then runs those functions. And you probably want to remove this: add_action( ‘wp_enqueue_scripts’, ‘crunchify_print_scripts_styles’); … because you aren’t able to get the return result … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)