database - Exporting revisions

admin2025-01-07  4

How do you export revisions for posts?

I cloned a site with it's complete Wordpress DB 4 months ago.

After the clone revisions have been made to the existing posts and new posts has been added to the original DB.

How can i extract these revisions and add them to the new DB's pages/posts? Or export them in their entirety with all revision data? (No changes has been made to the clone)

It seems you can only export posts via the Wordpress Export Tool, but this doesn't export the revisions, and also doesn't add new revisions to existing posts.

Is this feasible through a custom advanced queries or with a plugin?

The logic for such a query would look something like:

1) Get all posts from date to date

2) Extract them WITH all of their revisions (instead of wordpress export that ignores all revisions and only exports the final post)

3) On import add new revisions to existing posts

4) Or add new posts with all revisions

I guess as long as you can compare posts in the two DB's and be certain that they are the same regardless of different ID's you should be able to add new revisions to existing posts. So maybe the point of comparison should be the GUID.

Thanks!

How do you export revisions for posts?

I cloned a site with it's complete Wordpress DB 4 months ago.

After the clone revisions have been made to the existing posts and new posts has been added to the original DB.

How can i extract these revisions and add them to the new DB's pages/posts? Or export them in their entirety with all revision data? (No changes has been made to the clone)

It seems you can only export posts via the Wordpress Export Tool, but this doesn't export the revisions, and also doesn't add new revisions to existing posts.

Is this feasible through a custom advanced queries or with a plugin?

The logic for such a query would look something like:

1) Get all posts from date to date

2) Extract them WITH all of their revisions (instead of wordpress export that ignores all revisions and only exports the final post)

3) On import add new revisions to existing posts

4) Or add new posts with all revisions

I guess as long as you can compare posts in the two DB's and be certain that they are the same regardless of different ID's you should be able to add new revisions to existing posts. So maybe the point of comparison should be the GUID.

Thanks!

Share Improve this question edited Nov 18, 2018 at 20:08 lowkey asked Nov 18, 2018 at 17:39 lowkeylowkey 1505 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Your requirements involve a non-standard process since WordPress does not natively support exporting or importing post revisions. However, this is achievable through custom database queries.

WordPress stores posts and their revisions in the wp_posts table. Revisions are stored as separate entries with the post_type set to revision and a reference to the original post in the post_parent column. The GUID or post_name can act as the comparison key between posts across the databases.

Here is a SQL statement to extract your revisions:

SELECT p.*
FROM wp_posts p
WHERE (p.post_type = 'post' OR p.post_type = 'page') -- Include posts/pages
AND (p.post_date BETWEEN '2024-01-01' AND '2024-07-01') -- Adjust date range
OR (p.post_type = 'revision' AND p.post_parent IN (
   SELECT ID FROM wp_posts
   WHERE post_date BETWEEN '2024-01-01' AND '2024-07-01'
));
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736258625a528.html

最新回复(0)