我看了一下wp_revisions_to_keep()
作用有一个过滤器叫做wp_revisions_to_keep
覆盖的值WP_POST_REVISIONS
.
下面是一个未经测试的示例(PHP 5.4+):
add_filter( \'wp_revisions_to_keep\', function( $num, $post )
{
// Post Types and Revision Numbers - Edit to your needs
$config = [
\'post\' => 10,
\'page\' => 9,
\'cpt\' => 8
];
// Get the current post type
$post_type = get_post_type( $post );
// Override the WP_POST_REVISIONS value
if( isset( $config[$post_type] ) && is_int( $config[$post_type] ) )
$num = $config[$post_type];
return $num;
}, 10, 2 );
但我认为这种配置作为插件比主题相关更有意义。