网上目前能找到两种方法:
1、找到wp-admin/includes/post.php里边的get_default_post_to_edit这个函数,
$post = get_post( wp_insert_post( array( ‘post_title’ => __( ‘Auto Draft’ ), ‘post_type’ => $post_type, ‘post_status’ => ‘auto-draft’ ) ) );
把这一句修改成如下:
$post_auto_draft = $wpdb->get_row( “SELECT * FROM $wpdb->posts WHERE post_type = ‘$post_type’ AND post_status = ‘auto-draft’ LIMIT 1” );
if ( $post_auto_draft ) {
$post = $post_auto_draft;
} else {
$post = get_post( wp_insert_post( array( ‘post_title’ => __( ‘Auto Draft’ ), ‘post_type’ => $post_type, ‘post_status’ => ‘auto-draft’ ) ) );
}
意思就是: 如果有自动保存的auto-draft就使用以前的auto-draft的ID来写文章,如果没有就插入一条auto-draft, 最后,数据库中总有一条auto-draft… 虽然数据库会多一条数据,但ID还是可以保持连续.
2、找到wp-admin\includes\post.php文件,在if ( $create_in_db ) {前面加上这句代码就可以了:
$create_in_db = false;
发表回复