WordPress 联系表 7:“发送”按钮未提交,重定向到同一页面(jquery / 锚点导航)
我正在开发一个使用 jquery.slideto.js 导航系统和 html 锚点的 WordPress 页面。我正在使用 Contact Form 7 插件,
当按下“发送”按钮时,表单不会提交,并且包含的 jQuery 验证脚本不会触发。相反,它只是重新加载当前页面而不提交。
我已将表单包含在另一个页面上,没有所有额外的代码,并且表单确实发送,但是 jQuery 验证都不起作用,并且它通过将“#wpcf7-f1-p93-o1”附加到当前 URL 来导航到新页面
我在模板文件中使用以下代码
<?php
global $wpcf7_contact_form;
if ( ! ( $wpcf7_contact_form = wpcf7_contact_form( 1 ) ) )
return 'Contact form not found!';
$form = $wpcf7_contact_form->form_html();
echo $form;
?>
问题页面的网址是:www.beattrainsoundsystem.com/home#contact(或单击导航中的“联系”链接)
工作但有问题的页面的网址是: www.beattrainsoundsystem.com/test
我已经禁用了除联系表单 7 之外的所有 WordPress 插件以及除 jQuery 之外的所有脚本,以缩小问题根源。我确实需要在周一继续开发,因此在接下来的 24 小时内(从美国东部标准时间周日凌晨 1:48 开始)它将处于调试模式。非常感谢您的帮助!
如果您需要我对页面进行任何更改以帮助您调试,请告诉我。
I am developing a WordPress page that uses a jquery.slideto.js navigation system and html anchors. I am using the Contact Form 7 plugin
When pressing the "send" button, the form does not submit, and the included jQuery validation script does not fire. Instead, it just reloads the current page without submitting.
I have included the form on another page without all the extra code and the form DOES send, but none of the jQuery validation works, and it navigates to a new page by appending "#wpcf7-f1-p93-o1" to the current URL
I'm using the following code in my template file
<?php
global $wpcf7_contact_form;
if ( ! ( $wpcf7_contact_form = wpcf7_contact_form( 1 ) ) )
return 'Contact form not found!';
$form = $wpcf7_contact_form->form_html();
echo $form;
?>
The url of the problem page is: www.beattrainsoundsystem.com/home#contact (or click the "Contact" link in the nav)
the url of the working but buggy page is: www.beattrainsoundsystem.com/test
I've disabled all wordpress plugins except for contact form 7, and all scripts except jQuery to narrow down the source of the problem. I do need to continue developing on Monday, so for the next 24 hours (starting Sunday @ 1:48am EST) it will be in debug mode. Thanks so much for your help!
Let me know if you need me to make any changes to the page to help you help me debug.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有很多问题,但这里的主要问题是解决方案问题:
我在上面问题中引用的 PHP 有缺陷。我认为重要的是(至少在我的情况下有这么多其他脚本/插件/变量等...)联系表单 7 坚持使用他们在编辑器中给您的标签(“[contact-form 1”联系表单 1 “]”)。因此,我的解决方案是在名为“contactForm”的类别中创建一个名为“contactForm”的帖子,并从主页检索该帖子:
我会向有类似问题的任何人推荐该解决方案。
A lot of issues here, but here is the main issue that was the solution problem:
The PHP that I quoted in the above question was flawed. I think it's important (at least in my case with so many other scripts/plugins/variables etc...) with contact form 7 to stick with the tag they give you in the editor ("[contact-form 1 "Contact form 1"]"). So my solution was to create a post called "contactForm" in a category called "contactForm" and retrieve that post from the home page:
I would recommend that solution for anyone having a similar problem.