wp_is_post_autosave( int|WP_Post $post ): int|false

Determines if the specified post is an autosave.


Parameters

$post int|WP_Post Required
Post ID or post object.

Top ↑

Return

int|false ID of autosave's parent on success, false if not a revision.


Top ↑

Source

File: wp-includes/revision.php. View all references

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;
}


Top ↑

Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.