- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
プラグイン API/フィルターフック一覧/wp revisions to keep
Description
The wp_revisions_to_keep filter allows developers to easily alter how many revisions are kept for a given post.
By default, an infinite number of revisions are stored if a post type supports revisions.
Usage
When the 'wp_revisions_to_keep' filter is called, it is passed two parameters: number of revisions to keep, and the WP_Post object of the current post.
add_filter( 'wp_revisions_to_keep', 'filter_function_name', 10, 2 ); function filter_function_name( $num, $post ) { return $num; }
Where 'filter_function_name' is the function WordPress should call when filter is run. Note that the filter function must return a value after it is finished processing or the revisions will be empty.
filter_function_name should be unique function name. It cannot match any other function name already declared.
Examples
By post type
Sets the number of revisions for a theoretical post type 'my_custom_post'.
add_filter( 'wp_revisions_to_keep', 'filter_function_name', 10, 2 ); function filter_function_name( $num, $post ) { if( 'my_custom_post' == $post->post_type ) { $num = 5; } return $num; }
Change Log
- Since: 3.6.0
See Also
- Index: List of filters
- Tutorial: Creating a Filter Function
- Function: add_filter(), wp_revisions_to_keep()
最新英語版: WordPress Codex » Plugin_API/Filter_Reference/wp_revisions_to_keep (最新版との差分)