Home » Functions » wp_get_post_revisions

Function Name: wp_get_post_revisions

WordPress allows users to save and track the history of their content revisions with the wp_get_post_revisions function. This function retrieves all revisions of a given post or page. The function accepts a single argument, which is the ID of the post or page.

The wp_get_post_revisions function can be useful for bloggers and content creators who want to keep track of changes made to their content over time. This function can help users revert to a previous version of their content if they made a mistake or want to undo changes made to their content.

Here is an example of how to use the wp_get_post_revisions function:

$post_id = 123;

$revisions = wp_get_post_revisions( $post_id );

foreach ( $revisions as $revision ) {
   // Do something with each revision

In this example, the wp_get_post_revisions function is used to retrieve all revisions of a post with an ID of 123. The revisions are then looped through using a foreach loop, allowing you to perform actions on each revision.

Learn More on WordPress.org

WordPress snippets using the wp_get_post_revisions function

Register an account to save your snippets or go Pro to get more features.