WordPress
红楼梦:黄金万两容易得,知心一个也难求
使用记录
- 禁用自动保存和修订版本,节省数据库空间
- 修改主题模板下functions.php
php
//禁用文章自动保存
add_action('wp_print_scripts', 'disable_autosave');
function disable_autosave() {
wp_deregister_script('autosave');
}
//禁用文章修订版本
add_filter( 'wp_revisions_to_keep', 'specs_wp_revisions_to_keep', 10, 2 );
function specs_wp_revisions_to_keep( $num, $post ) {
return 0;
}
- 修改网站根目录wp-config.php
php
define('WP_DEBUG', false); #后面添加
/** Disable autosave and revision */
define('AUTOSAVE_INTERVAL', false );
define('WP_POST_REVISIONS', 36000 );
- 删除已保存的修订记录
php
DELETE FROM wp_postmeta WHERE post_id IN (SELECT id FROM wp_posts WHERE post_type = 'revision');
DELETE FROM wp_term_relationships WHERE object_id IN (SELECT id FROM wp_posts WHERE post_type='revision');
DELETE FROM wp_posts WHERE post_type='revision';