PHP WordPress Enqueue jQuery - 谷歌CDN

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP WordPress Enqueue jQuery - 谷歌CDN相关的知识,希望对你有一定的参考价值。

------------------------------------------------

This must be inserted into the functions.php file:

function modify_jquery() {
	if (!is_admin()) {
		// comment out the next two lines to load the local copy of jQuery
		wp_deregister_script('jquery');
		wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', false, '1.6.1');
		wp_enqueue_script('jquery');
	}
}
add_action('init', 'modify_jquery');

------------------------------------------------

This must be inserted into the header.php file (BEFORE WP_HEAD CALL!):

<?php wp_enqueue_script("jquery"); ?>

------------------------------------------------

jQuery functions should be wrapped in this so that $ operator represents no-conflict (BELOW WP_HEAD):

<script type='text/javascript'>
jQuery(document).ready(function($) {
	
	
    // $() will work as an alias for jQuery() which is noconflict mode inside of this function
});
</script>

------------------------------------------------

以上是关于PHP WordPress Enqueue jQuery - 谷歌CDN的主要内容,如果未能解决你的问题,请参考以下文章

php 在Wordpress中使用'wp_enqueue_scripts'操作将Vue.js排入队列

Wordpress:wp_enqueue_style 不起作用

样式表将自动删除/取消注册 - WordPress

Sidr 导航在 Wordpress 中不起作用

如何在父主题css之后加载wordpress子主题css

为什么wp_enqueue_style在这里不起作用?