Determines if the specified post is an autosave.
Parameters
$postint|WP_Postrequired- Post ID or post object.
Source
function wp_is_post_autosave( $post ) {
$post = wp_get_post_revision( $post );
if ( ! $post ) {
return false;
}
if ( str_contains( $post->post_name, "{$post->post_parent}-autosave" ) ) {
return (int) $post->post_parent;
}
return false;
}
Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |
Check if a saved post is an autosave post, like saving meta box data.