如何在我的Wordpress页脚中包含Jquery? [英] How can I include Jquery in my Wordpress footer?

查看:78
本文介绍了如何在我的Wordpress页脚中包含Jquery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想每10秒加载一次php脚本.加载代码不是问题,但是在Wordpress中,所有插件都使用它们自己的Jquery库,如果我只是添加jquery google链接,则:

I want to .load the php script every 10 seconds. The load code is not a problem, but in Wordpress all plugins use their own Jquery libraries, and if I just add the jquery google link:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>

其他插件将崩溃.

我的页脚中有以下代码:

I have the following code in my footer:

<?php
if ( is_user_logged_in() ) {
include 'completed.php';
}
?>

我想包含一个jquery脚本,以便执行以下代码:

I want to include a jquery script so I can execute the following code:

<?php
if ( is_user_logged_in() ) { ?>
<div id="completed">
    <script>
    $(function(){
        setInterval(function(){
               $("#completed").load("completed.php");
        }, 10 * 1000);
    });
    </script>
</div>
<?php } ?>

您认为您可以帮助我吗?

Do you think you can help me out?

推荐答案

从页脚的Google ajax库中加载jquery

Load the jquery from google ajax library in footer

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.9.1/jquery.min.js', false, '1.3.2', true); 
        wp_enqueue_script('jquery');
    }
}
add_action('init', 'my_init');

这篇关于如何在我的Wordpress页脚中包含Jquery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆