Php jqueryajax打破了我的Divi主题。我怎么修理它?

Php jqueryajax打破了我的Divi主题。我怎么修理它?,php,jquery,wordpress,wordpress-theming,Php,Jquery,Wordpress,Wordpress Theming,我目前正在进行一个项目,我的脚本将模式代码添加到导航中。jQuery代码确实有效 但是,当我为ajax.googleapis.com添加链接时,它会破坏所有其他Divi样式的脚本。如果有任何帮助,我将不胜感激!请在下面查看我的编码。我把它放在一个子主题中,代码存储在functions.php文件中 我正在使用的主题生成器是Div <?php function load_js() { if(!is_admin()) { echo '<script type

我目前正在进行一个项目,我的脚本将模式代码添加到导航中。
jQuery
代码确实有效

但是,当我为ajax.googleapis.com添加链接时,它会破坏所有其他Divi样式的脚本。如果有任何帮助,我将不胜感激!请在下面查看我的编码。我把它放在一个子主题中,代码存储在
functions.php
文件中

我正在使用的主题生成器是Div

<?php


function load_js()
{

    if(!is_admin())
   { 
    echo '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>';

      echo '<script type="text/javascript">
jQuery( document ).ready(function(){

    // Put itemscope and itemtype into navigation ul
    $("nav ul").attr("itemscope", "").attr("itemtype", "http://www.schema.org/SiteNavigationElement");
    // put itemprop in lis
    $("nav ul li").attr("itemprop", "name");
    //put itemprop url in anchors
    $("nav ul li a").attr("itemprop", "url");

}); 

 </script>';
   }


}

add_action( 'wp_footer', 'load_js');

经过思考和其他一些项目的工作,我已经完成并解决了这个问题

问题在于,用于拉入ajax jquery库的脚本正在加载到中,而不是加载到中。因此,我做了一些简单的更改,您可以在下面查看以查看修复

    <?php


    function load_js()
    {

        if(!is_admin())
       { 

          echo '<script type="text/javascript">
    $( document ).ready(function(){

        // Put itemscope and itemtype into navigation ul
        $("nav ul").attr("itemscope", "").attr("itemtype", "http://www.schema.org/SiteNavigationElement");
        // put itemprop in lis
        $("nav ul li").attr("itemprop", "name");
        //put itemprop url in anchors
        $("nav ul li a").attr("itemprop", "url");

    });  
</script>';
       }


    }

add_action( 'wp_footer', 'load_js');

// load ajax jquery for schema nav
function ajax_jquery()
{
    if(!is_admin())
    {
        echo '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>';
    }
}
add_action( 'et_head_meta', 'ajax_jquery');

经过思考和其他一些项目的工作,我已经完成并解决了这个问题

问题在于,用于拉入ajax jquery库的脚本正在加载到中,而不是加载到中。因此,我做了一些简单的更改,您可以在下面查看以查看修复

    <?php


    function load_js()
    {

        if(!is_admin())
       { 

          echo '<script type="text/javascript">
    $( document ).ready(function(){

        // Put itemscope and itemtype into navigation ul
        $("nav ul").attr("itemscope", "").attr("itemtype", "http://www.schema.org/SiteNavigationElement");
        // put itemprop in lis
        $("nav ul li").attr("itemprop", "name");
        //put itemprop url in anchors
        $("nav ul li a").attr("itemprop", "url");

    });  
</script>';
       }


    }

add_action( 'wp_footer', 'load_js');

// load ajax jquery for schema nav
function ajax_jquery()
{
    if(!is_admin())
    {
        echo '<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>';
    }
}
add_action( 'et_head_meta', 'ajax_jquery');

您的
的结束标记在哪里?它们在那里。当我把它们放进上面的文本编辑器时,出于某种原因,它把它们取了出来。我会看看我是否能做一个屏幕截图。太酷了!抱歉,仍在学习如何使用此功能!谢谢@Samuel@我没问题,伙计,欢迎来到SO!如果删除jquery,它不会影响任何东西吗?我认为jquery已经包含在wordpress中了。您只需将其包括在内。您的
的结束标记在哪里?它们在那里。当我把它们放进上面的文本编辑器时,出于某种原因,它把它们取了出来。我会看看我是否能做一个屏幕截图。太酷了!抱歉,仍在学习如何使用此功能!谢谢@Samuel@我没问题,伙计,欢迎来到SO!如果删除jquery,它不会影响任何东西吗?我认为jquery已经包含在wordpress中了。你只要把它包括进去就行了。