Filter hook 'wp_revisions_to_keep'

in WP Core File wp-includes/revision.php at line 821

View Source

wp_revisions_to_keep

Filter Hook
Description
Filters the number of revisions to save for the given post. Overrides the value of WP_POST_REVISIONS.

Hook Information

File Location wp-includes/revision.php View on GitHub
Hook Type Filter
Line Number 821

Hook Parameters

Type Name Description
int $num Number of revisions to store.
WP_Post $post Post object.

Usage Examples

Basic Usage
<?php
// Hook into wp_revisions_to_keep
add_filter('wp_revisions_to_keep', 'my_custom_filter', 10, 2);

function my_custom_filter($num, $post) {
    // Your custom filtering logic here
    return $num;
}

Source Code Context

wp-includes/revision.php:821 - How this hook is used in WordPress core
<?php
 816  	 * @since 3.6.0
 817  	 *
 818  	 * @param int     $num  Number of revisions to store.
 819  	 * @param WP_Post $post Post object.
 820  	 */
 821  	$num = apply_filters( 'wp_revisions_to_keep', $num, $post );
 822  
 823  	/**
 824  	 * Filters the number of revisions to save for the given post by its post type.
 825  	 *
 826  	 * Overrides both the value of WP_POST_REVISIONS and the {@see 'wp_revisions_to_keep'} filter.

PHP Documentation

<?php
/**
	 * Filters the number of revisions to save for the given post.
	 *
	 * Overrides the value of WP_POST_REVISIONS.
	 *
	 * @since 3.6.0
	 *
	 * @param int     $num  Number of revisions to store.
	 * @param WP_Post $post Post object.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/revision.php
Related Hooks

Related hooks will be displayed here in future updates.