In wp-config.php
you’re able to change how WordPress deals with post revisions. Specifically you’re able to turn them off or specify a max number of revisions.
I’d like to be able to set a max number or revisions on a post type basis.
Is this possible?
Remove the action
'wp_save_post_revision'
from'pre_post_update'
. It is set per default inwp-includes/default-filters.php
with the default priority (10).Add your own function to this hook. You get the
$post_ID
as parameter, so detecting the post type is easy.In your callback copy the code from
wp_save_post_revision()
but use the constantWP_POST_REVISIONS
for the post typepost
only, and use different values for other post types. Not sure if it is possible to pass extra values inregister_post_type()
â¦This is possible but it’s not as simple as changing the
WP_POST_REVISIONS
property in thewp-config.php
. This is possible by adding a filter to the ‘wp_insert_post_data’.Adding a filter is done like this: