wp_is_post_autosave

The timeline below displays how wordpress function wp_is_post_autosave has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Determines if the specified post is an autosave.
 *
 * @since 2.6.0
 *
 * @param int|WP_Post $post Post ID or post object.
 * @return int|false ID of autosave's parent on success, false if not a revision.
 */
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;
}

WordPress Version: 5.4

/**
 * Determines if the specified post is an autosave.
 *
 * @since 2.6.0
 *
 * @param int|WP_Post $post Post ID or post object.
 * @return int|false ID of autosave's parent on success, false if not a revision.
 */
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;
}

WordPress Version: 5.3

/**
 * Determines if the specified post is an autosave.
 *
 * @since 2.6.0
 *
 * @param int|WP_Post $post Post ID or post object.
 * @return false|int False if not a revision, ID of autosave's parent otherwise
 */
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;
}

WordPress Version: 4.3

/**
 * Determines if the specified post is an autosave.
 *
 * @since 2.6.0
 *
 * @param int|WP_Post $post Post ID or post object.
 * @return false|int False if not a revision, ID of autosave's parent otherwise
 */
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;
}

WordPress Version: 3.7

/**
 * Determines if the specified post is an autosave.
 *
 * @since 2.6.0
 *
 * @param int|object $post Post ID or post object.
 * @return bool|int False if not a revision, ID of autosave's parent otherwise
 */
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;
}