Wordpress中的静态页面

时间:2017-03-07 17:14:06

标签: php wordpress wordpress-theming

在我创建联系表单的wordpress中,我调用了发送电子邮件的testmail.php文件?因为当我调用文件示例时:hostname / a / testmail.php - >网页未找到。目录a / testmail.php在themes / ownthemes文件夹中,但是我无法访问testmail.php。

这种方法有可能吗?

谢谢

3 个答案:

答案 0 :(得分:0)

请不要在WP主题内创建另一个入口点。 有很好的插件可以发送表单:https://wordpress.org/plugins/ninja-forms/ https://wordpress.org/plugins/contact-form-7/

如果您真的想要构建自己的脚本,请使用AJAX操作https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action) 或者在WP环境中运行代码的其他钩子。

在主题中创建入口点会导致代码重复和安全问题。

答案 1 :(得分:0)

有可能。您需要致电hostname/a/testmail.php,而不是致电hostname/wp-content/themes/yourtheme/a/testmail.php。或者将文件放在http根目录中(wp-content,wp-admin等文件夹所在的位置)。
这是一种让它快速运行的方法,但我建议使用类似AJAX的动作如果你想获得更好的产值,克斯特亚会回答。

答案 2 :(得分:0)

所以使用插件如:联系form7来处理这样的功能是个好主意 如果你仍然需要调用外部脚本编写的PHP,但有麻烦(得到404错误)你得到这个,因为wordpress /主机的.htaccess文件。 样本:

    IndexIgnore *

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\\.)?example.com/.*$ [NC]
RewriteRule \\.(gif|jpg|js|css)$ - [F]

# BEGIN WordPress
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress