wp_{$post->post_type}_revisions_to_keep
云策文档标注
概述
此过滤器用于根据文章类型动态控制保存的修订版本数量。它覆盖了 WP_POST_REVISIONS 常量和 'wp_revisions_to_keep' 过滤器的值。
关键要点
- 过滤器名称是动态的,基于 $post->post_type,例如 wp_post_revisions_to_keep 或 wp_page_revisions_to_keep。
- 参数包括 $num(整数,要保存的修订数量)和 $post(WP_Post 对象)。
- 在 WordPress 5.8.0 版本中引入。
代码示例
$num = apply_filters( "wp_{$post->post_type}_revisions_to_keep", $num, $post );注意事项
此过滤器优先于其他修订控制机制,使用时需注意避免冲突。
原文内容
Filters the number of revisions to save for the given post by its post type.
Description
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:
wp_post_revisions_to_keepwp_page_revisions_to_keep
Parameters
$numint-
Number of revisions to store.
$postWP_Post-
Post object.
Source
$num = apply_filters( "wp_{$post->post_type}_revisions_to_keep", $num, $post );
Changelog
| Version | Description |
|---|---|
| 5.8.0 | Introduced. |