wp_(post_type)_revisions_to_keep filter-hookWP 5.8.0

Filters the number of revisions to save for the given post by its post type.

Overrides both the value of WP_POST_REVISIONS and the wp_revisions_to_keep filter.

The dynamic portion of the hook name, $post->post_type, refers to the post type slug.

Possible hook names include:


add_filter( 'wp_(post_type)_revisions_to_keep', 'wp_kama_post_type_revisions_to_keep_filter', 10, 2 );

 * Function for `wp_(post_type)_revisions_to_keep` filter-hook.
 * @param int     $num  Number of revisions to store.
 * @param WP_Post $post Post object.
 * @return int
function wp_kama_post_type_revisions_to_keep_filter( $num, $post ){

	// filter...
	return $num;
Number of revisions to store.
Post object.


Since 5.8.0 Introduced.

Where the hook is called

wp-includes/revision.php 849
$num = apply_filters( "wp_{$post->post_type}_revisions_to_keep", $num, $post );

Where the hook is used in WordPress

Usage not found.