简体   繁体   English

如何在我的Wordpress页脚中包含Jquery?

[英]How can I include Jquery in my Wordpress footer?

I want to .load the php script every 10 seconds. 我想每10秒加载一次php脚本。 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: 加载代码不是问题,但在Wordpress中,所有插件都使用自己的Jquery库,如果我只是添加jquery google链接:

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

the other plugins will crash. 其他插件会崩溃。

I have the following code in my footer: 我的页脚中有以下代码:

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

I want to include a jquery script so I can execute the following code: 我想包含一个jquery脚本,以便我可以执行以下代码:

<?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? 你认为你可以帮助我吗?

Load the jquery from google ajax library in footer 从页脚中的google ajax库加载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.9.1/jquery.min.js', false, '1.3.2', true); 
        wp_enqueue_script('jquery');
    }
}
add_action('init', 'my_init');

But why won't you do use the built in jQuery in no-conflict mode so that nothing crashes. 但是为什么不在无冲突模式下使用内置的jQuery,以免造成任何崩溃。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的插件,wordpress之外包含一个php文件? - How can I include a php file outside of my plugin,wordpress? 如何在我的wordpress博客中放置一个Subscribe2插件形式? (例如:页脚) - How can I place a form of Subscribe2 plugin in my wordpress blog? (Example: Footer) 如何使页脚部分仅在我的wordpress主页上可见? - How can I make , a footer section, visible only in my wordpress frontpage? 我如何将这个jquery代码包含到wordpress中? - How would I include this jquery code to wordpress? 如何在CGI脚本中包含Wordpress页眉/页脚 - How to include Wordpress header/footer in CGI script 如何在wordpress页脚中包含php并在页面上调用 - how to include php in wordpress footer and call on pages 如何防止访问我的PHP包含header.php,footer.php之类的文件? - How can I prevent access to my PHP include files like header.php, footer.php and the likes? 如何在非WordPress php文件中包含WordPress页眉和页脚 - How to Include WordPress Header and Footer in non-WordPress php file 如何在Wordpress中包含一个PHP文件,该文件不在我的主题中,而是在同一台服务器上? - How can I include a PHP file in Wordpress that is outside of my theme but on the same server? 我的页眉和页脚菜单无法同时显示在我的wordpress主题中 - I can't get both my header and footer menus to display properly in my wordpress theme
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM