【问题标题】:Contact form 7 seems not to work with foundation. No console errors though联系表格 7 似乎不适用于基金会。虽然没有控制台错误
【发布时间】:2014-02-24 13:18:05
【问题描述】:

有链接: http://lavii.ee/proov 联系表格无法正常工作。

正如联系表 7 所指 - 它似乎是 ajax error。无法弄清楚那里到底出了什么问题......

【问题讨论】:

  • 那里没有任何问题。它工作正常,确认和所有。它只是很慢。
  • 其实不是。有两件事 - 1)它将#wpcf7-f4-p2-o1添加到网站url末尾2)它刷新页面(它不应该)和第三个3)当我尝试使用以下链接时应该重定向页面,它不会工作。 on_sent_ok: "位置 = 'example.com/';"哦,如果我们将其与 this 进行比较,则没有旋转箭头
  • 老兄.. 下次请详细说明一下。仅仅说“不工作”是不够的。这里的人们无法猜测出什么问题。请添加代码(来自 wpcf7 的表单字段)或更多可使用的内容......对于最终用户只需提交表单即可。

标签: javascript jquery wordpress contact-form-7


【解决方案1】:

有很多事情会导致您在上面(在 cmets 中)描述的错误。

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

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

wp-foundation 主题实际上是在使用一个非常糟糕的做法,即注销 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 本身...

【讨论】:

    猜你喜欢
    • 2014-10-05
    • 2020-08-05
    • 1970-01-01
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    相关资源
    最近更新 更多