Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Wordpress中使用PHP页脚重定向_Php_Wordpress_Redirect_Placeholder - Fatal编程技术网

在Wordpress中使用PHP页脚重定向

在Wordpress中使用PHP页脚重定向,php,wordpress,redirect,placeholder,Php,Wordpress,Redirect,Placeholder,我有一个关于PHP中定时重定向的问题,特别是在wordpress中 我们已经设置了一个网站使用免费的Woothemes占位符主题,这是非常有限的。但这没关系——网站很简单 20秒后,我希望页面重定向到另一个URL-是否可以在footer.php中插入一些代码来执行此操作?我找到了正确的代码: //延迟重定向: 标题('刷新:20;url=http://www.example.org/'); 是否可以将其插入footer.php中的哪个位置 欢迎任何输入。您只需在header.php中编写即可 &

我有一个关于PHP中定时重定向的问题,特别是在wordpress中

我们已经设置了一个网站使用免费的Woothemes占位符主题,这是非常有限的。但这没关系——网站很简单

20秒后,我希望页面重定向到另一个URL-是否可以在footer.php中插入一些代码来执行此操作?我找到了正确的代码:

//延迟重定向:
标题('刷新:20;url=http://www.example.org/');

是否可以将其插入footer.php中的哪个位置


欢迎任何输入。

您只需在header.php中编写即可

<META HTTP-EQUIV="Refresh" CONTENT="20;URL=http://www.google.com">


是,这可以在页脚中使用。但请确保在标题中设置了
ob\u start()
。否则会出现错误。

是的,可以插入,但如果服务器已经发送了某些HTML,您将收到一条警告,例如,…
已发送的
头,重定向将无法正常工作

相反,您可以通过使用将要打印的内容清除输出缓冲区中的所有内容,然后发送重定向标头来执行此操作

例如:

if($casespecial==true) {
    ob_clean(); //make sure nothing is outputed to the browser
    header('Refresh: 20; url=http://www.example.org/'); //now send the header param

    //After wards, you can resume your normal code and output the template as you require
    .
    .
    .
}

你试过了吗?没有理由不这样做。