我认为使用redirect_post_location
(参见codex) 钩子是一种更好的方法-它只在这个特定的上下文中触发(当帖子在编辑后被重定向时-see code).
add_filter(\'redirect_post_location\', \'redirect_after_post_update\', 10, 2 );
function redirect_after_post_update( $location, $post_id ) {
// make sure we\'re in dashboard
if ( ! is_admin() ) {
return $location;
}
// check if post was published, not updated
if ( ! isset( $_POST[ \'publish\' ] ) ) {
return $location;
}
$new_post_sceen = get_admin_url( \'\', \'post-new.php\');
if ( ! empty( $new_post_sceen ) ) {
return $new_post_sceen;
}
return $location;
}