简体   繁体   中英

Wordpress ReferenceError: jQuery is not defined

I keep getting this error.

I just have my plugin installed on my WP site which calls some .js files with jquery and jquery-ui-core as dependencies.

I call them like so:

wp_enqueue_script(
        'vkrwpsprojs',
        plugins_url( '/js/vkrwpsprojs.js', __FILE__ ), 
        array( 'jquery' )
    );

    wp_enqueue_script(
        'fancybox',
        plugins_url( '/js/jquery.fancybox.js', __FILE__ ), 
        array( 'jquery-ui-core' )
    );

The head sections of my page ( where the .js files start to get includes ) looks like so:

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js?ver=4.0" type="text/javascript"></script>
<script src="http://l/demorwpspro/wp-includes/js/jquery/jquery.js?ver=1.11.1" type="text/javascript"></script>
<script src="http://l/demorwpspro/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1" type="text/javascript"></script>

Is the problem that jquery-ui is called before jquery? If so, how to make jquery appear before jquery-ui? The ordering that exists now shoud include jquery first and then jquery-ui, but it's not.

Check out this useful tutorial . Also make sure you include jQuery the right way. I think that is the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM