Using Astra theme, I cannot use jQuery on the frontend. It keeps logging Uncaught ReferenceError: jQuery is not defined at VM105:23
. It is actually supposed that Wordpress is equipped with jQuery, but I cannot figure out why I get that 'undefined' error message in console.
So as to add jQuery, I just write the following code, yet to no effect:
function addjq () {
wp_enqueue_script('jquery', plugin_dir_url(__FILE__) . '/in/jq.js', array('jquery'), null, false);
}
add_action('wp_enqueue_scripts', 'addjq');
I am using this piece inside a widget, and it is not including jquery
to the frontend. It actually comes up with that Uncaught ReferenceError
. Is the problem somehow related to my jquery
file url, or is it a core problem that I need to address. Can you help me out of the problem, and let me know how I can use jquery
inside a plugin widget
. The following jQuery code throws that console error:
jQuery(document).ready(function() {
// Some Code Goes Here...
})
I also tried to add a src
attribute to the script tag, and bring in the jQuery. RESULT
: The error disappeared, yet no jQuery code was run. Even I could not do a simple console.log()
.
Thanks in advance...
question from:
https://stackoverflow.com/questions/65647424/missing-jquery-in-a-wordpress-widget 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…