wp_get_post_revisions

The timeline below displays how wordpress function wp_get_post_revisions has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Returns all revisions of specified post.
 *
 * @since 2.6.0
 *
 * @see get_children()
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
 * @param array|null  $args Optional. Arguments for retrieving post revisions. Default null.
 * @return WP_Post[]|int[] Array of revision objects or IDs, or an empty array if none.
 */
function wp_get_post_revisions($post = 0, $args = null)
{
    $post = get_post($post);
    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'));
    $revisions = get_children($args);
    if (!$revisions) {
        return array();
    }
    return $revisions;
}

WordPress Version: 5.3

/**
 * 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($args, array('post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit'));
    $revisions = get_children($args);
    if (!$revisions) {
        return array();
    }
    return $revisions;
}

WordPress Version: 4.5

/**
 * 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($args, array('post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit'));
    if (!$revisions = get_children($args)) {
        return array();
    }
    return $revisions;
}

WordPress Version: 4.1

/**
 * Returns all revisions of specified post.
 *
 * @since 2.6.0
 *
 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
 * @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($args, array('post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit'));
    if (!$revisions = get_children($args)) {
        return array();
    }
    return $revisions;
}

WordPress Version: 4.0

/**
 * Returns all revisions of specified post.
 *
 * @since 2.6.0
 *
 * @uses get_children()
 *
 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
 * @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($args, array('post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit'));
    if (!$revisions = get_children($args)) {
        return array();
    }
    return $revisions;
}

WordPress Version: 3.7

/**
 * Returns all revisions of specified post.
 *
 * @since 2.6.0
 *
 * @uses get_children()
 *
 * @param int|object $post_id Post ID or post object
 * @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', '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;
}