这不是错误,WordPress
故意这样做(以保存修订版 AFAIK)。无论如何,这可能有效,但可能比这更好(粘贴到您的functions.php
文件中)
add_action( 'admin_notices', 'custom_error_notice' );
function custom_error_notice(){
global $current_screen, $post;
if ( $current_screen->parent_base == 'edit' ){
if((!$post->post_name && !$post->post_content) && $_GET['post']) {
wp_redirect(admin_url('post-new.php?empty=1'));
}
if($_GET['empty']) echo '<div class="error"><p>Warning - Please fill up all fields correctly!</p></div>';
}
}
此外,这是使用wp_redirect
and to所必需的,将其avoid header already sent error message
粘贴到functions.php
所有其他代码的顶部
function callback($buffer) {
// You can modify $buffer here, and then return the updated code
return $buffer;
}
function buffer_start() { ob_start("callback"); }
function buffer_end() { ob_end_flush(); }
// Add hooks for output buffering
add_action('init', 'buffer_start');
add_action('wp_footer', 'buffer_end');