Using WordPress ‘post_revisions_meta_box()’ PHP function

The post_revisions_meta_box() WordPress PHP function displays a list of revisions for a post.

Usage

post_revisions_meta_box($post);

Parameters

  • $post (WP_Post) – Required. The current post object.

More information

See WordPress Developer Resources: post_revisions_meta_box()

Examples

Display Revisions for a Custom Post Type

This example demonstrates how to display revisions for a custom post type called “book.”

function book_revisions_meta_box() {
    global $post;
    post_revisions_meta_box($post);
}
add_meta_box('book_revisions', 'Book Revisions', 'book_revisions_meta_box', 'book', 'side', 'low');

Add a Revisions Meta Box to a Custom Post Type with a Custom Name

This example shows how to add a revisions meta box with a custom name to a custom post type called “portfolio.”

function portfolio_revisions_meta_box() {
    global $post;
    post_revisions_meta_box($post);
}
add_meta_box('portfolio_revisions', 'Portfolio Revisions', 'portfolio_revisions_meta_box', 'portfolio', 'side', 'low');

Add a Revisions Meta Box to a Custom Post Type with a Custom Context

This example demonstrates how to add a revisions meta box to a custom post type called “event” with a custom context, such as the “normal” context.

function event_revisions_meta_box() {
    global $post;
    post_revisions_meta_box($post);
}
add_meta_box('event_revisions', 'Event Revisions', 'event_revisions_meta_box', 'event', 'normal', 'low');

Add a Revisions Meta Box to a Custom Post Type with a Custom Priority

This example shows how to add a revisions meta box to a custom post type called “recipe” with a custom priority, such as the “high” priority.

function recipe_revisions_meta_box() {
    global $post;
    post_revisions_meta_box($post);
}
add_meta_box('recipe_revisions', 'Recipe Revisions', 'recipe_revisions_meta_box', 'recipe', 'side', 'high');

Remove the Default Revisions Meta Box and Add a Custom One

This example demonstrates how to remove the default revisions meta box from the “post” post type and add a custom revisions meta box with a custom name.

function remove_default_revisions_meta_box() {
    remove_meta_box('revisionsdiv', 'post', 'normal');
}
add_action('admin_menu', 'remove_default_revisions_meta_box');

function custom_post_revisions_meta_box() {
    global $post;
    post_revisions_meta_box($post);
}
add_meta_box('custom_post_revisions', 'Custom Post Revisions', 'custom_post_revisions_meta_box', 'post', 'normal', 'low');