第一步:找到并打開 wp-config.php 文件,在 $table_prefix = 'wp_';前面添加如下代碼:
- define('AUTOSAVE_INTERVAL', false ); //自動保存時間
- define('WP_POST_REVISIONS', false); //修定版本開啟/關閉
第二步:找到并打開 wp-adminpost-new.php 和 wp-adminpost.php 這兩個文件,將其 “wp_enqueue_script(‘autosave’);” 注釋或刪除掉,特別要注意一下,post.php和post-new.php這兩個文件在很多文件夾里面都有,注意路徑,前往不要改錯了.
實例代碼如下:
//wp_enqueue_script('autosave');
第三步:找到并打開 wp-adminincludespost.php 文件,找到如下代碼:
- if ( $create_in_db ) {
- // Cleanup old auto-drafts more than 7 days old
- $old_posts = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_status = 'auto-draft' AND DATE_SUB( NOW(), INTERVAL 7 DAY ) > post_date" );
- foreach ( (array) $old_posts as $delete )
- wp_delete_post( $delete, true ); // Force delete
- $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
- $post = get_post( $post_id );
- if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
- set_post_format( $post, get_option( 'default_post_format' ) );
- } else {
替換成如下代碼:
- if ( $create_in_db ) {
- global $current_user;//獲取當前登錄管理用戶
- $post = $wpdb->get_row( "SELECT * FROM $wpdb->posts WHERE post_status = 'auto-draft' AND post_type = '$post_type' AND post_author = $current_user->ID ORDER BY ID ASC LIMIT 1" );//獲取最早一條自動草稿
- if ( !$post ) {
- $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
- $post = get_post( $post_id );
- }
- if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) )
- set_post_format( $post, get_option( 'default_post_format' ) );
- } else {
注意:修改完成后系統已無自動保存功能,需要手工保存草稿.
新聞熱點
疑難解答
圖片精選