Skip to content

Instantly share code, notes, and snippets.

@loorlab
Last active October 11, 2024 03:10
Show Gist options
  • Select an option

  • Save loorlab/360855351bb3af056da35ceff11a8c35 to your computer and use it in GitHub Desktop.

Select an option

Save loorlab/360855351bb3af056da35ceff11a8c35 to your computer and use it in GitHub Desktop.
Query - MySQL - WordPress | Display Post Revisions
SELECT
p.ID AS original_post_id,
p.post_title AS original_post_title,
p.post_modified AS last_modified_date,
r.ID AS revision_id,
r.post_modified AS revision_date,
u.display_name AS author_name,
u.user_email AS author_email
FROM
wp_posts p
LEFT JOIN
wp_posts r ON r.post_parent = p.ID AND r.post_type = 'revision'
LEFT JOIN
wp_users u ON r.post_author = u.ID
WHERE
p.ID = 2804 -- ID Post
ORDER BY
r.post_modified DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment