您的位置:首页 > 其它

解决wordpress使用wp_redirect函数出现Warning: Cannot modify header information的方法

2016-09-11 09:38 771 查看
php中使用重定向跳转时,“Warning: Cannot modify header information – headers already sent by (output started at…”是常见的错误提醒,出现该错误的原因是跳转函数前有包括回车、空格、换行的输出,解决方法是使用ob_start()函数打开缓冲区,使用跳转前 的输入进入缓冲区而不会立即输出,避免这个错误提醒。近两天博客吧制作的wordpress主题中出现该提示,解决方法是在主题 functions.php文件中使用ob_start()函数。

在出现该错误的主题functions.php文件添加代码:
1
2
3
4

add_action('init', 'do_output_buffer');
function do_output_buffer() {
ob_start();
}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐