你好我试图从WordPress网站上的页面中的URL打印一个值
我编辑了header.php并输入了以下代码
<?php
$town = rawurldecode( $_GET['town'] ); ?>
页面上的我要打印我添加的值
<?php print $town ?>
我已经尝试了一些允许在页面中使用php的插件,但是我得到了错误
网址看起来像这样
website.co.uk/page/?town=abc
我尝试的结果是在页面中需要时使用PHP标记
例如
Hello i live in <?php print $town ?>, would you like to
come see the football in <?php print $town ?>?.
Did you know that <?php print $town ?> is not that far?
答案 0 :(得分:1)
答案 1 :(得分:0)
更改
$town = rawurldecode( $_GET['town'] );
到
if(isset($_GET['town'])) { $town = rawurldecode( $_GET['town'] ); } else { $town = "No town"; }
并改变
<?php print $town ?>
到
<?php echo $town; ?>
也许这会奏效,请告诉我们结果。