“警告:无法修改标题信息"在 Wordpress 3.6.1 中 [英] "Warning: Cannot modify header information" in Wordpress 3.6.1
本文介绍了“警告:无法修改标题信息"在 Wordpress 3.6.1 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在 Wordpress3.6.1 的测试插件中使用 wp_redirect,这是一个简单的插件,但它不起作用.这是我的代码:
I tried to use wp_redirect in my test plugin in Wordpress3.6.1, this is a simple plugin but it did not work. This is my code:
<?php
/*
Plugin Name: Test
Plugin URI: http://localhost
Description: This is just test plugin
Author: author
Version: 1.0
Author URI: http://localhost
*/
function test_menu(){
$page_title = 'Test';
$menu_title = 'Test';
$capability = 'manage_options';
$menu_slug = 'test-menu';
$function = 'my_test';
add_menu_page($page_title, $menu_title, $capability,$menu_slug, $function);
}
add_action('admin_menu', 'test_menu');
function my_test(){
wp_redirect("http://www.google.com.vn");
exit;
}
当单击测试"菜单时,我收到警告:
When click Test menu, i got a warning:
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\wp3.6.1\wp-admin\includes\template.php:1706) in C:\AppServ\www\wp3.6.1\wp-includes\pluggable.php on line 875
请帮帮我,这段代码发生了什么
Please help me, what's happen with this code
推荐答案
尝试使用 ob_start()
add_action('init', 'do_output_buffer');
function do_output_buffer() {
ob_start();
}
这篇关于“警告:无法修改标题信息"在 Wordpress 3.6.1 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文