WordPress at a glance

wp_get_post_revisions() WP 1.0

Returns all revisions of specified post.

  • See: get_children()
Works based on: get_children()

No Hooks.

Return

Array. An array of revisions, or an empty array if none.

Usage

wp_get_post_revisions( $post_id, $args );
$post_id(int/WP_Post)
Post ID or WP_Post object.
Default: global $post
$args(array/null)
Arguments for retrieving post revisions.
Default: null

Code of wp_get_post_revisions: wp-includes/revision.php VER 5.0

<?php
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( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) );

	if ( ! $revisions = get_children( $args ) )
		return array();

	return $revisions;
}

Related Functions

From tag: post revisions

No comments
    Hello, !     Log In . Register