-1

我正在尝试将以下代码添加到表单的操作部分中:

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 解决了这个问题:

将 PHP 的结果存储到变量中,并将变量附加到表单操作中,如下所示:

$permalink = get_permalink();

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

4

3 回答 3

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'>";
于 2012-10-17T15:31:35.480 回答
0
action="<?php echo_the_permalink(); ?>?rest_part_of=url"

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

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

其中1是 url 的参数?

于 2012-10-17T14:58:33.577 回答
0

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

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

这应该够了吧。或者试试ern0的答案

于 2012-10-17T15:22:17.530 回答