使用 WordPress comments.php 文件作为联系表单
我想使用内置的联系表单构建我的 WP 主题。没有验证码的简单事情。我想仅使用 Akismet 作为垃圾邮件过滤器。所以,我的第一个想法是将 comments.php 页面“转换”为联系页面模板。我明白了,但有些地方需要改进。
1)当您使用该联系人时,不会通知内容是否已发送。我如何为用户添加“谢谢”消息?
2)如您所知,通过这种方法,联系信息不会发送到我的电子邮件。相反,它出现在评论管理页面中。有没有机会让 WP 真正将联系信息发送到我的电子邮件中?
正如我之前所说,我不想使用插件,所以如果您知道如何帮助我解决这些问题或解决此问题的新方法,我们将不胜感激。
I want to build my WP theme with a built in contact form. Something simple without captcha. I would like to use just Akismet as a spam filter. So, my first thought was to "convert" the comments.php page into a contact page template. Which I got it, but some points need to be improve.
1) When you use the contact, there is no notification if the content was sent it or not. How could I put a "Thank You" message for the user?
2) As you know, with this approach the contact info doesn't go to my email. Instead it's appear in the comments admin page. Is there any chance to make WP really send me the contact info to my email?
As I said before, I don't want to use a plugin, so if you have any idea how to help me to solve these issues or a new approach to this, it will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该简单地使用 php 邮件功能与表单数据。如果您不习惯使用插件,您仍然应该查看一些简单的插件以获取代码示例。
有很多带有联系形式的免费开源主题,您也可以使用作为示例。您还应该考虑为已有联系表单的主题创建一个 WordPress 子主题。这是干净而简单的解决方案。
You should simply use php mail function with your form data. If you don't wont to use plugin, you should still look at some simple plugin for code examples.
There are a lot of free open source themes with contat form you can also use as example. You should also consider creating a wordpress child theme for the theme that already has contact form. That is clean and simple solution.
为什么不使用插件呢?为什么“你不想”?
它可以将 1 小时的编程时间缩短为 5 分钟。
最好的办法是编辑评论模板表单,这样它就不会在每个页面或帖子中显示评论,例如 single.php、index.php、page.php
让表单仅显示。
当您这样做时,您可以进入“设置”->“ “讨论设置”
comment
勾选上述选项。你应该可以走了。
Why not use a plug-in? WHY "don't you want" to?!
It can turn 1 hour of programming to 5 minutes.
Your best bet is to edit the comment-template form so it doesn't display the comments in each page or post such as single.php, index.php, page.php
Let the form only display.
When you do that, you can go into your Settings -> "Discussion Settings"
comment
Checkbox the above options. And you should be good to go.