Using wp_enqueue_script or wp_print_script function you can load your JS file after jQuery loaded. Usage Reference –
<?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>
The $dep
argument (dependencies) should be an array or null or empty, and should not be used the way you did on your code. It will be on with wp_enqueue_script or wp_print_script function.
Your first used add_action
reference is valid, but the second one is invalid.
On your stb_enqueue_scripts
function, it should be –
function stb_enqueue_scripts()
{
// third argument is the dependencies, should be array or boolean false
// fifth argument = boolean true if loading the script at footer
wp_enqueue_script( 'script-name', 'script_url', array('jquery'), '', true );
}
Related Posts:
- force enqueue script to be first in order of prominence
- WordPress Enqueue Script Chaos (jQuery & Foundation.js)
- Calling JavaScript file with Custom Plugin
- Problem in loading javascript in footer
- jQuery for custom plugin not working with Divi theme
- Create shortcode to echo javascript
- Enqueue script: link not working in page source
- force jQuery to load in the head
- How to install jquery dotdotdot plugin for WordPress?
- Redux Framework: Page freezes on typing in Editor
- How can I inject options into an select tag inside the widget form?
- jquery tinymce and bundled wp plugins
- Display wordpress post’s in popup?
- How to prevent plugins from loading jQuery
- Using color picker in plugin, does input attribute order matter?
- JQuery plugin that works with Google 1.10.2 and not with WordPress 1.10.2
- Loading a purchased jquery plugin in a wordpress theme
- Using window.onload with Ubermenu
- Post Comments with Ajax in WordPress
- jQuery | JJ Carousel Plugin – Can’t set speed [closed]
- How can I remove the WordPress-Version (?ver=5.x) from my plugin
- Integrating jQuery Datatables with Editor into wordpress admin
- how to insert data in wordpress table usnig jquery ajax
- Stop WordPress processing Javascript as text
- Jquery plugin not working on single pages
- Jquery NoConflict Problem
- this jQuery function works perfect in static html page but not on wordpress
- How to include this jQuery File in wordpress?
- Is there a loading priority for login_enqueue_scripts?
- AJAX fileupload – TypeError: not a function ajaxSubmit()
- “Conflict” with jQuery (or its plugins)?
- How does one include the JQuery UI plugin to wordpress and enque it correctly in a plugin form?
- a weird attribute on every html tag
- Why am I unable to load scripts in head in plugin?
- How to add an element right after the article using jQuery?
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- Deactivate JS Script in Plugin Shortcode
- How to track clicks
- Remove / overwrite some functions in buddypress.js
- wordpress add_action() issue in ajax call
- Remove Yoast jQuery from front end
- How to display checked posts on another page over AJAX? (like comparasion style)
- Adding media upload button to User Profile page (following a tutorial)
- Localizing methods for jQuery append prepend wrap parent
- JQuery prepend a function
- Register google jquery gets overwritten by plugin
- Is there a function to list all uploaded images? How can I add one?
- How to best create a jQuery Slider to display a native wordpress gallery?
- How to remove js ui library added by default by wordpress
- Add type to enqueued script inside plugin
- I changed .live() to .on() but change is not reflected on the server
- wp_dequeue_script for a Plugin
- Creating a widget and missing jQuery
- Stop wordpress from requesting external jquery from googleapi
- Plugin not working & permalink erorr after upgrade to php 7x on Nginx
- Save user total active time after login in wordpress [closed]
- Opening a JQuery modal window on click of a button with a JQuery plugin
- Custom plugin – load enqueue only for this plugin
- Api external with wordpress
- Why does my jQuery plugin show up as text in WordPress?
- JQuery needs to be defined in , but Gravity Forms is defining it in the
- How do I make sure that my plugin only runs on article detail pages?
- Disable submit button order
- Why do I get jQuery reference error / undefined when changing name of plugin file?
- Deregister scripts from plugin
- Custom meta box with jQuery.sortable custom post type list
- How to include my Ajax calls in one function instead of calling different ones every time?
- How to prevent tabs from opening all at once
- Why jquery option is not working when pass value using wp_localize_script?
- Custom CSS not being added by plugin
- Load CSS files in header of Bones theme?
- jQuery code didn’t run on my plugin
- The Events Calendar Plugin – List View Background Colour Issue [closed]
- why the wp_register_script doesn’t work for register_activation_hook
- “switchEditors is not defined” with wp_editor() in jQuery UI tabs
- Separate jQuery for Individual Comments?
- How to enqueue some javascript source once per page
- FancyBox JS stopped working on multiple sites. Custom plugin responsible. Urgent help needed
- Portfolio Slideshow Sliders Behaving Oddly When in jQuery Ui Tabs
- jQuery(‘#news-ticker’).cycle is not a function
- JS Plugin not executing the js correctly. Trying to make all internal links scroll smoothly
- Call javascript functions from each page
- Using AJAX to run SQL statement and populate dropdown
- WordPress slider that allows image, headline, text, and button?
- Ajax request sends url rather than data
- Javascript from Easy-Fancybox place into footer
- Adding a jQuery modal dialog to the admin area
- Error jQuery(domChunk).live is not a function
- WordPress plugin isn’t loading completely
- jQuery slider widget similar to cnet.com
- Problems with jQuery and is_admin()
- sliding/fading header plugin or approach suggestion
- What is the most effecient way of enqueuing scripts based on the current plugins template?
- FacetWP breaks jQuery events
- Edit all $wp_scripts at once to $in_footer = false
- Edit all $wp_scripts at once to $in_footer = false
- Pass PHP variable to javascript
- Cannot read properties of undefined (reading ‘firstChild’) using photoswipe in product page
- Trigger jQuery to add events after AJAX-loading table in admin plugin
- WordPress load same script two times