wp_get_post_revisions

Advertisement

Summery Summery

Returns all revisions of specified post.

Syntax Syntax

wp_get_post_revisions( int|WP_Post $post_id, array|null $args = null )

Parameters Parameters

$post_id

(Optional) Post ID or WP_Post object. Default is global $post.

$args

(Optional) Arguments for retrieving post revisions.

Default value: null

Return Return

(array) An array of revisions, or an empty array if none.

Source Source

File: wp-includes/revision.php

	return $delete;
}

/**
 * Returns all revisions of specified post.
 *
 * @since 2.6.0
 *
 * @see get_children()
 *
 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global `$post`.
 * @param array|null  $args    Optional. Arguments for retrieving post revisions. Default null.
 * @return array An array of revisions, or an empty array if none.
 */
function wp_get_post_revisions( $post_id = 0, $args = null ) {
	$post = get_post( $post_id );
	if ( ! $post || empty( $post->ID ) ) {
		return array();
	}

	$defaults = array(
		'order'         => 'DESC',
		'orderby'       => 'date ID',
		'check_enabled' => true,
	);
	$args     = wp_parse_args( $args, $defaults );

	if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) {
		return array();
	}

	$args = array_merge(

Advertisement

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

See also See also

Advertisement

Leave a Reply