A WordPress-centric search engine for devs and theme authors



wp_is_post_autosave ›

Since2.6.0
Deprecatedn/a
wp_is_post_autosave ( $post )
Parameters:
  • (int|WP_Post) $post Post ID or post object.
    Required: Yes
Returns:
  • (false|int) False if not a revision, ID of autosave's parent otherwise
Defined at:
Codex:

Determines if the specified post is an autosave.



Source

function wp_is_post_autosave( $post ) {
	if ( !$post = wp_get_post_revision( $post ) )
		return false;

	if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) )
		return (int) $post->post_parent;

	return false;
}