wp_is_post_autosave( int|WP_Post $post )
Determines if the specified post is an autosave.
Description Description
Parameters Parameters
- $post
-
(int|WP_Post) (Required) Post ID or post object.
Return Return
(false|int) False if not a revision, ID of autosave's parent otherwise
Source Source
File: wp-includes/revision.php
function wp_is_post_autosave( $post ) {
$post = wp_get_post_revision( $post );
if ( ! $post ) {
return false;
}
if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) {
return (int) $post->post_parent;
}
return false;
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Check if a saved post is an autosave post, like saving meta box data.
// If post is an autosave, return. if ( wp_is_post_autosave( $post_id ) ) { return; }