Function Signature:
wp_get_post_revisions
Function Description:
Returns all revisions of specified post.
Function Examples:
⚠️ Examples below are generated with GPT-3 once every hour. Do not take them too seriously.
Consider them as some extra input in your learning process - reason about them. Will it work? What could fail?
// Example 1: Retrieve all post revisions for a specific post ID
$post_id = 123;
$revisions = wp_get_post_revisions($post_id);
if (empty($revisions)) {
echo 'No revisions found for this post.';
} else {
foreach ($revisions as $revision) {
echo 'Revision ID: ' . $revision->ID . ', Author: ' . $revision->post_author . ', Date: ' . $revision->post_date . '
';
}
}
// Example 2: Limit the number of revisions to retrieve
$post_id = 456;
$revisions = wp_get_post_revisions($post_id, array('posts_per_page' => 5));
if (empty($revisions)) {
echo 'No revisions found for this post.';
} else {
foreach ($revisions as $revision) {
echo 'Revision ID: ' . $revision->ID . ', Author: ' . $revision->post_author . ', Date: ' . $revision->post_date . '
';
}
}
// Example 3: Exclude autosave revisions from the results
$post_id = 789;
$revisions = wp_get_post_revisions($post_id, array('check_enabled' => false));
if (empty($revisions)) {
echo 'No revisions found for this post.';
} else {
foreach ($revisions as $revision) {
echo 'Revision ID: ' . $revision->ID . ', Author: ' . $revision->post_author . ', Date: ' . $revision->post_date . '
';
}
}