apply_filters( ‘wp_revisions_to_keep’, int $num, WP_Post $post )

Filters the number of revisions to save for the given post.

Description

Overrides the value of WP_POST_REVISIONS.

Parameters

$numint
Number of revisions to store.
$postWP_Post
Post object.

More Information

  • By default, an infinite number of revisions are stored if a post type supports revisions.
  • Note that the filter callback functions must return a value after it is finished processing or the revisions will be empty.

Source

$num = apply_filters( 'wp_revisions_to_keep', $num, $post );

Changelog

VersionDescription
3.6.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Example migrated from Codex:

    The example below 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;
    }

You must log in before being able to contribute a note or feedback.