WordPress函数wp_get_post_revisions()获取一篇文章的所有修订版本信息

描述:

获取一篇文章的所有修订版本信息

用法:

<?php wp_get_post_revisions( $post_id, $args ); ?>

参数:

$post_id

(mixed) (必填) 文章ID

默认值: 0

$args

(array) (可选) 查询条件

默认值: None

有关参数$args接受的参数列表,请参阅WP_Query文档的parameters部分。

源文件:

/**
 * 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;
}