wpseek.com
A WordPress-centric search engine for devs and theme authors
wp_get_post_autosave › WordPress Function
Since2.6.0
Deprecatedn/a
› wp_get_post_autosave ( $post_id, $user_id = 0 )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Retrieve the autosaved data of the specified post.
Returns a post object containing the information that was autosaved for the specified post. If the optional $user_id is passed, returns the autosave for that user otherwise returns the latest autosave.
Related Functions: wp_create_post_autosave, wp_is_post_autosave, wp_get_post_cats, wp_get_post_tags, wp_set_post_cats
Source
function wp_get_post_autosave( $post_id, $user_id = 0 ) { $revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false ) ); foreach ( $revisions as $revision ) { if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) { if ( $user_id && $user_id != $revision->post_author ) { continue; } return $revision; } } return false; }