Javascript Enque脚本不适用于wordpress中的jQuery

Javascript Enque脚本不适用于wordpress中的jQuery,javascript,jquery,wordpress,Javascript,Jquery,Wordpress,我总是,总是很难让jQuery在wordpress中工作 我真的需要一些澄清和解释这件事是如何运作的 这是我的代码,我看不出有什么问题 在functions.php文件中: function my_init() { if (!is_admin()) { // comment out the next two lines to load the local copy of jQuery // wp_deregister_script('jquery'); // wp_re

我总是,总是很难让jQuery在wordpress中工作

我真的需要一些澄清和解释这件事是如何运作的

这是我的代码,我看不出有什么问题

在functions.php文件中:

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.3.2/jquery.min.js', false, '1.3.2'); 
    wp_enqueue_script('jquery');
} } add_action('init', 'my_init');
在调用其他jQuery脚本之前,这在我的页脚中:

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

还有一些答案

我在过去也遇到过这种情况,如果需要的话,我通常甚至不使用wordpress自己的jquery。因为服务器端的google方法更快。下面的代码必须工作

functions.php

<?php

function google_jquery() {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
    wp_enqueue_script( 'jquery' );
} 

add_action('wp_enqueue_scripts', 'google_jquery');

?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php wp_title(); ?> <?php bloginfo( 'name' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" media="screen" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_head(); ?>
</head>
<?php 
//Footer scripts
wp_footer(); 
?>
</body>
</html>

确保可湿性粉剂头();位于header.php文件中

header.php

<?php

function google_jquery() {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
    wp_enqueue_script( 'jquery' );
} 

add_action('wp_enqueue_scripts', 'google_jquery');

?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php wp_title(); ?> <?php bloginfo( 'name' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" type="text/css" media="screen" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_head(); ?>
</head>
<?php 
//Footer scripts
wp_footer(); 
?>
</body>
</html>


我也有这个问题。我的意思是我以某种方式加载它,但我总是遇到wp_enqueue_脚本的问题。你能描述一下你在这方面遇到了什么样的问题吗?是的,jQuery没有加载。我已经删除了它,并在文档中添加了一个脚本标记,它可以正常加载。但是就这样。。。不加载。