我使用jQuery Masonry构建了一个Wordpress主题。我在使用Google托管的jQuery脚本时在本地托管Masonry脚本。砌体工作得很好。但出于某种原因,我需要在页脚中调用Masonry和jQuery,以便Masonry工作。但这样做会禁用各种使用jQuery的Wordpress插件。看来我的插件需要在标题中调用jQuery,而Masonry需要它在页脚中。
如何解决此冲突?
答案 0 :(得分:1)
您应该使用wp_register_script
方法加载jQuery:
function my_init() {
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.7.2/jquery.min.js', false, '1.7.2');
wp_enqueue_script('jquery');
}
}
add_action('init', 'my_init');
http://www.ericmmartin.com/5-tips-for-using-jquery-with-wordpress/
答案 1 :(得分:0)