首页建站经验 解决wordpress使用wp_redirect函数出现Warning: Cannot modify header information的方 ...

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

php中使用重定向跳转时,“Warning: Cannot modify header information – headers already sent by (output started at…”是常见的错误提醒,出现该错误的原因是跳转函数前有…

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

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

add_action('init', 'do_output_buffer');

function do_output_buffer() {

ob_start();

}

本文来自网络,不代表1号站长-站长学院|资讯交流平台立场。转载请注明出处: https://www.1cn.cc/jianzhan/jingyan/18176.html
上一篇WordPress教程:自定义WP REST API (WP API)授权
下一篇 决定如何开发你的WordPress主题框架
admin

作者: admin

这里可以再内容模板定义一些文字和说明,也可以调用对应作者的简介!或者做一些网站的描述之类的文字或者HTML!

为您推荐

评论列表()

    联系我们

    联系我们

    0898-88888888

    在线咨询: QQ交谈

    邮箱: email@wangzhan.com

    工作时间:周一至周五,9:00-17:30,节假日休息

    关注微信
    微信扫一扫关注我们

    微信扫一扫关注我们

    关注微博
    返回顶部