2012-10-17 17 views
-1

我想下面的代码添加到我的表单的动作部分之外:添加PHP代码到一个表单动作打印数据的形式

action="'.the_permalink().'?filename.php=1" 

但这只会增加?filename.php=1到表单的动作和the_permalink( )结果在表格甚至开始之前打印在表格之外!

这是我的表格行:

form name="front_end_aa" method="POST" action="".the_premalink()."?assign-journalist=1" 

the_permalink()是WordPress的内部的功能,让你在点击后的链接。

解决:这是解决由于@enenen:

Store中的PHP的结果到一个变量,变量追加到表单的动作是这样的:

$permalink = get_permalink();

echo '<form name="front_end_aa" method="POST" action="'.$permalink.'?filename=1">

+0

你是指自己:HTTP:/ /codex.wordpress.org/Function_Reference/the_permalink?你在一个WordPress循环? –

+0

您可以提供'action = ...'整个行以及'the_permalink()'函数的代码。 – enenen

+0

@enenen当然检查我的原始问题 – Matt

回答

1

我还是不明白你在哪写你的form标签。所以......

如果是普通的HTML这将是:

<form name="front_end_aa" method="POST" action="<?php the_premalink(); ?>?assign-journalist=1"> 

而如果是PHP代码里面将是:

echo "<form name='front_end_aa' method='POST' action='".the_premalink()."?assign-journalist=1'>"; 
+0

@ enenen我已经稍微改变了这个'回声'

'但它是仍然把行动和形式标签 – Matt

+0

以外的永久链接我不知道'the_permalink()'实际上是如何工作的。也许你可以尝试用'$ permalink = get_permalink();'来获取URL,然后''echo'时使用'$ permalink'。 – enenen

+0

曾担任知府,谢谢。 – Matt

0
action="<?php echo_the_permalink(); ?>?rest_part_of=url" 

无论如何,这是丑陋的。写一个呈现整个URL的函数怎么样?

action="<?php echo_whole_url(1); ?>" 

其中是URL的参数?

+0

是否可以在这里实现该代码pastebin.com/RJXAwfWi – Matt

0

您需要一个存储由the_permalink()创建的值的变量:

$myLink = the_permalink(); 
echo '<form action="'.$myLink.'?filename.php=1">'; 

这应该做的伎俩。或者试试ern0的回答

+0

这种工作方式,但它吐在HTML中作为'http://custard-clients.co.uk/regionalfeed/web/gregre/ '我需要链接在?在行动 – Matt

相关问题