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?
- Pass PHP variable to javascript
- How can I make default jquery version of WordPress “async”?
- Get php var inside javascript file (making plugin)
- Handling jQuery Component Collision
- How to Add jQuery Infinite Scroll to My Custom Archive Page
- Get info (url) from already enqueued styles
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Editor not displaying dynamically after clicking on the button
- Check javascript file Proper way in functions.php
- Very stubborn wp_register_script / add_action vs remove
- WordPress Plugin development Call to undefined function jQuery()
- Dequeue / Deregister script and replace it with a new plugin
- wp_enqueue_scripts not working inside shortcode
- How to create popup same as wordpress popup feature
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- WordPress 3.5 Media Manager – add a button
- Handling jQuery Component Collision
- Register script in one plugin, and enqueue it in another
- How to remove style and js from theme and add your own style and js where shortcode is used?
- scrolltop always 0, can’t trigger script
- Use wp_enqueue_scripts from included php file
- Bootstrap Drop Down menu is not working
- Making a plugin only available on the front-end for the logged in super admin
- Change upload folder for a CPT
- Ajax contact form widget plugin data not insert in database
- How to hide CSS by default and show on button press
- Uncaught TypeError: jQuery(…).flipster is not a function in wordpress
- jquery tinymce and bundled wp plugins
- Display wordpress post’s in popup?
- Using color picker in plugin, does input attribute order matter?
- Using window.onload with Ubermenu
- jQuery | JJ Carousel Plugin – Can’t set speed [closed]
- Jquery plugin not working on single pages
- How to include this jQuery File in wordpress?
- Is there a loading priority for login_enqueue_scripts?
- “Conflict” with jQuery (or its plugins)?
- a weird attribute on every html tag
- How to add an element right after the article using jQuery?
- How to track clicks
- 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
- I changed .live() to .on() but change is not reflected on the server
- Save user total active time after login in wordpress [closed]
- Why does my jQuery plugin show up as text in WordPress?
- Disable submit button order
- Deregister scripts from plugin
- Why jquery option is not working when pass value using wp_localize_script?
- jQuery code didn’t run on my plugin
- The Events Calendar Plugin – List View Background Colour Issue [closed]
- “switchEditors is not defined” with wp_editor() in jQuery UI tabs
- Ajax request sends url rather than data
- Adding a jQuery modal dialog to the admin area
- sliding/fading header plugin or approach suggestion
- 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
- wc_get_template_part doesnt display the content [duplicate]
- Why do I need to reload the page for WordPress to see the new custom field added with jQuery
- Cannot pass value variable to WP AJAX functions
- How to properly enqueue jQuery knob on WordPress without conflict?
- How to get a specific string from a url
- Does anybody know how to insert a complete jquery plugin into a wordpress elementor-page?
- JS working when used normally but not in wordpress
- $wpdb not working wordpress plugin ajax call
- Scroll to ID broken in main menu
- WordPress Thickbox Navigation Issue in Gallery
- Dynamic input fields in WordPress Plugin
- Not displaying Woocommerce product page in lightbox
- Problem in functions.php file
- show-hide based on select option jquery wordpress
- Add HTML between feed items
- WordPress Feedback popup with date saved into table
- WordPress ajax not working in registration
- Like/Dislike Bar not working when updating
- jquery-issue: cannot load the basic jquery
- Possible jquery / library conflict in plugin usage
- Why won’t the Comprehensive Google Map Plugin load?
- plugin’s script and style enqueing not working on Thesis
- “The Events Calendar” Issues in WP 3.2
- Element works, but not on wordpress site [duplicate]
- WordPress site keeps getting flagged as malware [closed]
- FacetWP: Plugin breaks button/modal functionality inside searchable content area
- TypeErrors with Yoast, jQuery in conflict?
- JQuery UI plugin not working in IE7?
- Jquery based image accordian plugin
- Count div with class (.length) only shows 0 [closed]
- Jquery post responses 500 error after some time and lastly an 503 error
- wp_enqueue_script doesn’t load JS in plugin
- How to add an active state class to my info box