Title: _wp_post_revision_fields
Published: April 25, 2014
Last modified: May 20, 2026

---

# _wp_post_revision_fields( array|WP_Post $post = array(), bool $deprecated = false ): string[]

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Determines which fields of posts are to be saved in revisions.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#parameters)󠁿

 `$post`array|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
optional

A post array or a [WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
object being processed for insertion as a post revision.

Default:`array()`

`$deprecated`booloptional

Not used.

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#return)󠁿

 string[] Array of fields that can be versioned.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#source)󠁿

    ```php
    function _wp_post_revision_fields( $post = array(), $deprecated = false ) {
    	static $fields = null;

    	if ( ! is_array( $post ) ) {
    		$post = get_post( $post, ARRAY_A );
    	}

    	if ( is_null( $fields ) ) {
    		// Allow these to be versioned.
    		$fields = array(
    			'post_title'   => __( 'Title' ),
    			'post_content' => __( 'Content' ),
    			'post_excerpt' => __( 'Excerpt' ),
    		);
    	}

    	/**
    	 * Filters the list of fields saved in post revisions.
    	 *
    	 * 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'.
    	 *
    	 * @since 2.6.0
    	 * @since 4.5.0 The `$post` parameter was added.
    	 *
    	 * @param string[] $fields List of fields to revision. Contains 'post_title',
    	 *                         'post_content', and 'post_excerpt' by default.
    	 * @param array    $post   A post array being processed for insertion as a post revision.
    	 */
    	$fields = apply_filters( '_wp_post_revision_fields', $fields, $post );

    	// WP uses these internally either in versioning or elsewhere - they cannot be versioned.
    	foreach ( array( 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author' ) as $protect ) {
    		unset( $fields[ $protect ] );
    	}

    	return $fields;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/revision.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/revision.php#L22)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/revision.php#L22-L62)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#hooks)󠁿

 [apply_filters( ‘_wp_post_revision_fields’, string[] $fields, array $post )](https://developer.wordpress.org/reference/hooks/_wp_post_revision_fields/)

Filters the list of fields saved in post revisions.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#related)󠁿

| Uses | Description | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#)

| Used by | Description | 
| [WP_REST_Autosaves_Controller::create_post_autosave()](https://developer.wordpress.org/reference/classes/wp_rest_autosaves_controller/create_post_autosave/)`wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php` |

Creates autosave for the specified post.

  | 
| [_wp_post_revision_data()](https://developer.wordpress.org/reference/functions/_wp_post_revision_data/)`wp-includes/revision.php` |

Returns a post array ready to be inserted into the posts table as a post revision.

  | 
| [wp_create_post_autosave()](https://developer.wordpress.org/reference/functions/wp_create_post_autosave/)`wp-admin/includes/post.php` |

Creates autosave data for the specified post from `$_POST` data.

  | 
| [wp_get_revision_ui_diff()](https://developer.wordpress.org/reference/functions/wp_get_revision_ui_diff/)`wp-admin/includes/revision.php` |

Get the revision UI diff.

  | 
| [wp_restore_post_revision()](https://developer.wordpress.org/reference/functions/wp_restore_post_revision/)`wp-includes/revision.php` |

Restores a post to the specified revision.

  | 
| [wp_save_post_revision()](https://developer.wordpress.org/reference/functions/wp_save_post_revision/)`wp-includes/revision.php` |

Creates a revision for the current version of a post.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.5.0](https://developer.wordpress.org/reference/since/4.5.0/) | The optional `$autosave` parameter was deprecated and renamed to `$deprecated`. | 
| [2.6.0](https://developer.wordpress.org/reference/since/2.6.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/?output_format=md#comment-content-1525)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/_wp_post_revision_fields/#comment-1525)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_post_revision_fields%2F%23comment-1525)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_post_revision_fields%2F%23comment-1525)
 4.  **Using the function to get the list of revision fields:**
 5.      ```php
         foreach ( _wp_post_revision_fields() as $field => $field_title ) : /* ... */
         ```
     
 6.  **Using the function to prepare a post for insertion into the database as a revision:**
 7.      ```php
         $post = _wp_post_revision_fields( $post );
         ```
     
 8.  **For an autosave:**
 9.      ```php
         $post = _wp_post_revision_fields( $post, true );
         ```
     
 10.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_post_revision_fields%2F%3Freplytocom%3D1525%23feedback-editor-1525)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F_wp_post_revision_fields%2F)
before being able to contribute a note or feedback.