Read in English
How to Limit the Number of WordPress Revisions Stored — and Its Limitations
Frequently editing posts causes revisions to accumulate in the wp_posts table of the WordPress database. Adding a single WP_POST_REVISIONS constant to wp-config.php lets you set the maximum number of revisions stored per post, but autosaves are handled separately and always keep exactly 1 per user, regardless of this setting.
How Revisions Accumulate in the Database
Every time WordPress saves or publishes a post, it adds a revision to the wp_posts table. Revisions share the same table as regular posts but are distinguished by post_status set to ‘inherit’ and post_type set to ‘revision’. By default, all revisions accumulate indefinitely, so a frequently edited post can end up with dozens of rows attached to it.
Autosaves are treated separately from revisions. The official documentation states: “There is only ever a maximum of one autosave per user for any given post. New autosaves overwrite old autosaves.” This means autosaves are overwritten every 60 seconds, keeping only 1 at a time, so they do not cause the database to grow continuously. [1]
Limiting the Number of Stored Revisions with WP_POST_REVISIONS
To limit the number of stored revisions, add the following constant to wp-config.php.
“`
define( ‘WP_POST_REVISIONS’, 3 );
“`
According to the official documentation, the meaning of each value is as follows. [1]
- true or -1 (default): Store all revisions
- false or 0: Do not store revisions (however, 1 autosave is still kept)
- Integer > 0: Store that many revisions per post; any excess is automatically deleted on the next save
Two Limitations to Be Aware of Before Configuring This Setting
First, even if WP_POST_REVISIONS is set to 0, autosaves are not deleted. Autosaves are a separate mechanism that provides a recovery path when the browser closes or the connection drops during editing, so this protection is not affected by the constant setting.
Second, the WP_POST_REVISIONS setting only applies to revisions created after it is configured. Revisions that have already accumulated must be cleaned up using a separate plugin or a direct database query. There is no bulk-delete feature for revisions in the official UI, and the official documentation also states: “There is an API function to delete revisions, but there is no UI.”
Additionally, you can use the wp_revisions_to_keep filter to set different revision limits per post type. For example, if you need to keep 5 revisions for pages and 3 for regular posts, you can use this filter in your theme’s functions.php or a plugin. However, this increases the burden of code maintenance, so if a single limit can be applied across the entire site, the wp-config.php constant is the simpler option. [1]
Related Reading
References
Source Verification
The official source was verified on November 23, 2026. The content may be updated after that date, so please check the original source for the latest details.
日本語で読む
WordPressのリビジョン保存数を減らす方法とその限界
投稿を頻繁に編集すると、WordPressデータベースのwp_postsテーブルにリビジョンが蓄積されます。wp-config.phpにWP_POST_REVISIONSという定数を1つ追加することで、投稿1件あたりの最大リビジョン保存数を指定できますが、自動保存(autosave)はこの設定とは独立して扱われ、ユーザーごとに常に1件だけ保持されます。
リビジョンがDBに蓄積される仕組み
WordPressは投稿を保存または公開するたびに、wp_postsテーブルにリビジョンを追加します。リビジョンは通常の投稿と同じテーブルを共有しますが、post_statusが’inherit’、post_typeが’revision’に設定されることで区別されます。デフォルトではすべてのリビジョンが無期限に蓄積されるため、編集頻度の高い投稿には数十件の行が付くこともあります。
自動保存(autosave)はリビジョンとは別に扱われます。公式ドキュメントには「There is only ever a maximum of one autosave per user for any given post. New autosaves overwrite old autosaves.」と明記されています。つまり自動保存は60秒ごとに上書きされ、常に1件のみ保持されるため、データベースが際限なく増加することはありません。 [1]
WP_POST_REVISIONSで保存数を制限する
保存数を制限するには、wp-config.phpに以下の定数を追加します。
“`
define( ‘WP_POST_REVISIONS’, 3 );
“`
公式ドキュメントによると、各値の意味は次のとおりです。 [1]
- true または -1(デフォルト): すべてのリビジョンを保存する
- false または 0: リビジョンを保存しない(ただし、自動保存1件は保持される)
- 0より大きい整数: 投稿1件あたりその数だけ保存し、超過分は次回保存時に自動削除される
設定前に確認しておくべき2つの限界
1つ目に、WP_POST_REVISIONSを0に設定しても、自動保存は削除されません。自動保存は編集中にブラウザが閉じられたり接続が切断されたりした際の復旧手段を提供する独立したメカニズムであるため、この保護機能は定数の設定に影響を受けません。
2つ目に、WP_POST_REVISIONSの設定は、設定後に発生するリビジョンにのみ適用されます。すでに蓄積された過去のリビジョンは、別途プラグインまたはDBへの直接クエリで整理する必要があります。公式UIにはリビジョンを一括削除する機能はなく、公式ドキュメントにも「There is an API function to delete revisions, but there is no UI.」と記載されています。
また、wp_revisions_to_keepフィルターを使うと、投稿タイプごとに保存数を個別に指定できます。たとえば固定ページは5件、通常の投稿は3件と分けたい場合は、テーマのfunctions.phpやプラグインでこのフィルターを活用できます。ただしこの場合はコード管理の負担が増すため、サイト全体に単一の基準を適用できるならwp-config.phpの定数の方がシンプルです。 [1]
あわせて読む
参考資料
資料確認基準
2026年11月23日に公式原文を確認しました。資料はその後更新される可能性があるため、詳細は原文をご確認ください。
글을 자주 수정하면 워드프레스 데이터베이스의 wp_posts 테이블에 개정 이력이 쌓입니다. wp-config.php에 WP_POST_REVISIONS 상수 하나를 추가하면 글 1개당 보관할 최대 개정 수를 지정할 수 있지만, 자동저장(autosave)은 이 설정과 별개로 사용자당 1개씩 항상 유지됩니다.

개정 이력이 DB에 쌓이는 구조
워드프레스는 글을 저장하거나 발행할 때마다 개정 이력을 wp_posts 테이블에 추가합니다. 개정 이력은 일반 글과 같은 테이블을 공유하되, post_status가 'inherit', post_type이 'revision'으로 구분됩니다. 기본적으로 모든 개정 이력이 무기한 누적되므로, 수정이 잦은 글은 수십 개의 행이 붙기도 합니다.
자동저장(autosave)은 개정 이력과 별도로 취급됩니다. 공식 문서는 "There is only ever a maximum of one autosave per user for any given post. New autosaves overwrite old autosaves."라고 명시합니다. 즉 자동저장은 60초마다 덮어쓰기 방식으로 1개만 유지되고, DB가 계속 늘어나지 않습니다. [1]
WP_POST_REVISIONS로 보관 수 제한하기
보관 수를 제한하려면 wp-config.php에 아래 상수를 추가합니다.
“`
define( 'WP_POST_REVISIONS', 3 );
“`
공식 문서에 따르면 이 값의 의미는 다음과 같습니다. [1]
- true 또는 -1 (기본값): 모든 개정 이력을 보관
- false 또는 0: 개정 이력을 저장하지 않음 (단, 자동저장 1개는 유지)
- 정수 > 0: 글 1개당 해당 개수만큼 보관하고, 초과분은 다음 저장 시 자동 삭제
설정 전에 확인할 두 가지 한계
첫째, WP_POST_REVISIONS를 0으로 설정해도 자동저장은 삭제되지 않습니다. 자동저장은 편집 중 브라우저가 꺼지거나 연결이 끊겼을 때 복구 경로를 제공하는 별도 메커니즘이므로, 이 보호 기능은 상수 설정의 영향을 받지 않습니다.
둘째, WP_POST_REVISIONS 설정은 이후 발생하는 개정 이력에만 적용됩니다. 이미 쌓인 과거 개정 이력은 별도의 플러그인이나 직접 DB 쿼리로 정리해야 합니다. 공식 UI에는 개정 이력을 일괄 삭제하는 기능이 없으며, 공식 문서도 "There is an API function to delete revisions, but there is no UI."라고 밝히고 있습니다.
추가로 wp_revisions_to_keep 필터를 사용하면 글 유형별로 보관 수를 다르게 지정할 수 있습니다. 예를 들어 페이지는 5개, 일반 글은 3개로 구분해야 한다면 테마의 functions.php나 플러그인에서 이 필터를 활용할 수 있습니다. 다만 이 경우 코드 관리 부담이 늘어나므로, 사이트 전체에 단일 기준을 적용할 수 있다면 wp-config.php 상수가 더 단순합니다. [1]
함께 읽기
참고한 자료
자료 확인 기준
2026년 11월 23일에 공식 원문을 확인했습니다. 자료는 이후 수정될 수 있으므로 세부 내용은 원문을 확인해 주세요.

답글 남기기