钩子文档

_wp_post_revision_fields

💡 云策文档标注

概述

_wp_post_revision_fields 是一个 WordPress 过滤器,用于控制保存文章修订时包含的字段列表。默认包含 'post_title'、'post_content' 和 'post_excerpt',并禁止某些字段如 'ID' 和 'post_status'。

关键要点

  • 过滤器名称:_wp_post_revision_fields
  • 默认字段:'post_title'、'post_content'、'post_excerpt'
  • 禁止字段:'ID'、'post_name'、'post_parent'、'post_date'、'post_date_gmt'、'post_status'、'post_type'、'comment_count'、'post_author'
  • 参数:$fields(字段数组)、$post(文章数组)
  • 用途:在 _wp_post_revision_fields() 函数中调用,确定修订保存的字段
  • 版本变更:4.5.0 添加 $post 参数,2.6.0 引入

代码示例

$fields = apply_filters( '_wp_post_revision_fields', $fields, $post );

📄 原文内容

Filters the list of fields saved in post revisions.

Description

Included by default: ‘post_title’, ‘post_content’ and ‘post_excerpt’.

Disallowed fields: ‘ID’, ‘post_name’, ‘post_parent’, ‘post_date’, ‘post_date_gmt’, ‘post_status’, ‘post_type’, ‘comment_count’, and ‘post_author’.

Parameters

$fieldsstring[]
List of fields to revision. Contains 'post_title', 'post_content', and 'post_excerpt' by default.
$postarray
A post array being processed for insertion as a post revision.

Source

$fields = apply_filters( '_wp_post_revision_fields', $fields, $post );

Changelog

Version Description
4.5.0 The $post parameter was added.
2.6.0 Introduced.