WordPress 联系表 7:“发送”按钮未提交,重定向到同一页面(jquery / 锚点导航)

发布于 2024-08-12 08:06:58 字数 842 浏览 3 评论 0原文

我正在开发一个使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红衣飘飘貌似仙 2024-08-19 08:06:58

这里有很多问题,但这里的主要问题是解决方案问题:

我在上面问题中引用的 PHP 有缺陷。我认为重要的是(至少在我的情况下有这么多其他脚本/插件/变量等...)联系表单 7 坚持使用他们在编辑器中给您的标签(“[contact-form 1”联系表单 1 “]”)。因此,我的解决方案是在名为“contactForm”的类别中创建一个名为“contactForm”的帖子,并从主页检索该帖子:

<?php $contact_drop = new WP_Query('p=109'); while ($contact_drop->have_posts()) : $contact_drop->the_post(); $do_not_duplicate = $post->ID; ?>
    <div id="contact-slide">
        <?php the_content(); ?>
    </div>
<?php endwhile; ?>

我会向有类似问题的任何人推荐该解决方案。

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:

<?php $contact_drop = new WP_Query('p=109'); while ($contact_drop->have_posts()) : $contact_drop->the_post(); $do_not_duplicate = $post->ID; ?>
    <div id="contact-slide">
        <?php the_content(); ?>
    </div>
<?php endwhile; ?>

I would recommend that solution for anyone having a similar problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文