如何将表单输入传递到Wordpress页面? [英] How to pass form input to Wordpress page?
问题描述
我的WordPress网站上存在一个小而持久的问题.
I've got a small but persistent issue on my WordPress website.
在我的主页上有一个表格:
On my homepage I have a form:
<form method='post' action='/test/' >
Input: <input type="text" name="input">
<input type="submit">
</form>
使用这种形式,我试图在另一页上传递并使用 input
值.
With this form I'm trying to pass and use the input
value on another page.
我认为 action
应该 ='test.php'
而不是/test/
(/test/
是常规WordPress页面的网址).我似乎无法访问URL中的任何 X.php
页面,因为每次都是404(不包括不是404的 index.php
,相反,它只是404)从 domain.com/index.php
重定向到 domain.com
I believe action
should = 'test.php'
not /test/
(/test/
is the URL of a regular WordPress page). I can't seem to access any X.php
pages in the URL, as it 404's every time (excluding index.php
, which doesn't 404, instead it just redirects from domain.com/index.php
to domain.com
我尝试创建一个新的php模板(可以用作页面模板来自定义/test/
页面),但是如果我尝试使用 action,它仍然是404.='new-template.php'
形式.
I've tried creating a new php template (which I can use as a page template to customize the /test/
page), but it still 404's if I try to use action = 'new-template.php'
in the form.
在这种情况下,关于如何将表单数据传递到另一个页面的任何建议?
Any suggestions on how I can pass the form data to another page in this scenario?
推荐答案
我可以举一个简单的例子,
I can give you a simple example,
第一个创建模板并将其分配给页面,例如test123//您可以在自定义站点地图创建中将其隐藏.
1st create a template and assign it to page eg. test123 // you can hide it from custom site map creation.
然后您可以将该页面称为表单提交页面
then you can call that page as form submit page
<form method='post' action='<?php bloginfo('url'); ?>/test123/' >
尝试此操作,您可以在模板中编写您的php代码.
try this you can write your php code inside the template.
这篇关于如何将表单输入传递到Wordpress页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!