Php wp_redirect()函数在wp admin中不起作用

Php wp_redirect()函数在wp admin中不起作用,php,redirect,plugins,wordpress,Php,Redirect,Plugins,Wordpress,我将在wordpress管理员中尝试以下重定向代码 if(isset($_POST['submit'])) { wp_redirect('admin.php?page=job-creation'); } 我还尝试wp_重定向('admin.php?page=job creation')而不是 wp_safe_redirect('admin.php?page=job-creation'); 及 所有代码在localhost中都工作正常。但它在网上(www.example.com)不

我将在wordpress管理员中尝试以下重定向代码

if(isset($_POST['submit'])) 
    {
wp_redirect('admin.php?page=job-creation');
}
我还尝试
wp_重定向('admin.php?page=job creation')而不是

wp_safe_redirect('admin.php?page=job-creation'); 

所有代码在localhost中都工作正常。但它在网上(www.example.com)不起作用


任何人都可以帮助我。

我认为这是针对您的web服务器配置,您不能在代码中的任何地方都使用头函数。 不要使用标题,而是使用以下内容:

print('<script>window.location.href="admin.php?page=job-creation"</script>');
print('window.location.href=“admin.php?page=job creation”);
这是一个用于重定向到另一个页面的简单javascript代码

更新


有关使用
标题的更多信息,请首先访问,使用后应始终退出

其次,您应该指定一个绝对URI。用这个

if( isset( $_POST['submit'] ) ){
  wp_redirect( admin_url( 'admin.php?page=job-creation' ) );
  exit;
}

如果url正确,请在重定向之前尝试使用
ob\u start()
函数。

在必须激活的插件中使用此代码

function callback($buffer) {
    // modify buffer here, and then return the updated code
    return $buffer;
}

function buffer_start() {
    ob_start("callback");
}

function buffer_end() {
    ob_end_flush();
}

add_action('init', 'buffer_start');
add_action('wp_footer', 'buffer_end');

我已经找到了解决办法。那你为什么在漫长的几天之后把答案放在这里呢@BoopathiRajan更多的答案可能会更好,或者在其他方面对其他人有所帮助。。。我希望这能解决你的疑问。。。
function callback($buffer) {
    // modify buffer here, and then return the updated code
    return $buffer;
}

function buffer_start() {
    ob_start("callback");
}

function buffer_end() {
    ob_end_flush();
}

add_action('init', 'buffer_start');
add_action('wp_footer', 'buffer_end');