wp_get_post_revisions( int|WP_Post $post_id, array|null $args = null )
Returns all revisions of specified post.
Description
See also
Parameters
Return
(array) An array of revisions, or an empty array if none.
More Information
See the parameters section of the WP_Query documentation for a list of parameters that the parameter $args
accepts.
Source
File: wp-includes/revision.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', ) ); $revisions = get_children( $args ); if ( ! $revisions ) { return array(); } return $revisions; }
Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_post_revisions