wp_is_post_revision() WordPress Function

The wp_is_post_revision() function allows you to check if the current post is a revision. This function is useful for making sure that you are only making changes to the most recent version of a post.

wp_is_post_revision( int|WP_Post $post ) #

Determines if the specified post is a revision.


Parameters

$post

(int|WP_Post)(Required)Post ID or post object.


Top ↑

Return

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


Top ↑

Source

File: wp-includes/revision.php

276
277
278
279
280
281
282
283
function wp_is_post_revision( $post ) {
    $post = wp_get_post_revision( $post );
    if ( ! $post ) {
        return false;
    }
 
    return (int) $post->post_parent;
}


Top ↑

Changelog

Changelog
VersionDescription
2.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.