联系表格7似乎与基金会无关。但是没有控制台错误

时间:2014-02-24 13:18:05

标签: javascript jquery wordpress contact-form-7

链接在那里: http://lavii.ee/proov 联系表格无法正常运作。

如联系表格7所示,它似乎是ajax error。不知道那里到底出了什么问题......

1 个答案:

答案 0 :(得分:0)

有很多事情可能导致您在上面描述的错误(在评论中)。

其中一个是分别在页眉和页脚中缺少wp_footer()wp_header()函数,但如果您没有手动删除它们,它们将包含在基础中。

另一个原因是错误加载js / jQuery。你的主题可能就是这种情况,因为wpcf7脚本似乎没有加载..

wp-foundation主题实际上是使用deregistring wp自己的jQuery并加载“个人”版本的非常糟糕的做法。

我甚至无法开始列举原因why it is wrong

虽然不是100%肯定,但这可能是其中一个原因(如果不是原因)

代码在functions.php

/************* ENQUEUE JS *************************/

/* pull jquery from google's CDN. If it's not available, grab the local copy. Code from wp.tutsplus.com :-) */

$url = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'; // the URL to check against  
$test_url = @fopen($url,'r'); // test parameters  
if( $test_url !== false ) { // test if the URL exists  

    function load_external_jQuery() { // load external file  
        wp_deregister_script( 'jquery' ); // deregisters the default WordPress jQuery  
        wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); // register the external file  
        wp_enqueue_script('jquery'); // enqueue the external file  
    }  

    add_action('wp_enqueue_scripts', 'load_external_jQuery'); // initiate the function  
} else {  

    function load_local_jQuery() {  
        wp_deregister_script('jquery'); // initiate the function  
        wp_register_script('jquery', bloginfo('template_url').'/javascripts/jquery.min.js', __FILE__, false, '1.7.2', true); // register the local file  
        wp_enqueue_script('jquery'); // enqueue the local file  
    }  

    add_action('wp_enqueue_scripts', 'load_local_jQuery'); // initiate the function  
}  

正确的代码应该只是

   function load_local_jQuery() {  

        wp_enqueue_script('jquery'); // enqueue the local file  
    }  

    add_action('wp_enqueue_scripts', 'load_local_jQuery'); // initiate the function  

加载wp自己的jQuery ......

另请参阅herehere

此外,在测试时禁用所有其他插件,并确保为wpcf7和wp本身使用最新版本...