Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been working alot with editing of posts after they've been published. I know I can hit update on the post to just update it, but I want to have the journey of revisions available for users to view on site.

So I was thinking of a plugin. I've looked at http://wordpress.org/extend/plugins/duplicate-post/ which creates another copy on a new permalink. This is a good starting point I think, but I'm wondering if the functionality could be done in reverse.

Functionality: When a post is updated (on every update no matter how small), it pushes the new updated content to the original post permalink, and moves the older post to a new permalink with a suffix of the update count.

Example: My post is called hello-world. I publish it and the permalink becomes http://mysite.com/hello-world. I need to edit it, so I go to posts and edit the page. I click update, and the original hello-world post is copied and published under hello-world-draft-1, and the newly updated post takes the place of the original hello-world post.

This way anyone linking to the post would always see the most up-to-date version of it, but all drafts would be available to view to any user by visiting /hello-world-draft-X, where 'X' is every update made that is not the main post slug.

I'm thinking this is something like being able to show revisions to the user? Comments and suggestions welcome.

Thanks.

Update: This plugin looks good but only works on uploaded .doc files and not posts. http://wordpress.org/extend/plugins/wp-document-revisions/

share|improve this question

1 Answer 1

Your question specifies that you are looking for 'suggestions' so this answer is in that category rather than in the 'working code' category.

I am going to start by saying that I don't know if this is a good idea. You are going to multiply the size of your database many times over. Now that is off my chest, if you are going to proceed here are my thoughts.

Don't write new posts for your 'revisions'. You will end up with every one of them in the RSS feeds, the post, index, the backend panels, etc. It would be a mess, and you'd have to put in a lot of work to hide them.

WordPress already has revisions, and all of the issues above have already been solved in core. Use them to your advantage.

Tell WordPress to keep all of your revisions.

define( 'WP_POST_REVISIONS', -1);

That is supposed to be the default but I'd set it just to be sure, in case a theme or plugin decides to think for you. Using the existing revisions will also alleviate the problem of increasing your database size. Unless you have turned off revisions, you already have this stuff in the database./

Now you need to work out how to display the revision.

wp_get_post_revisions($post_id) (assuming $post_id is set to the revision's parent post) should get you your revisions, which you can then use to create a list or a full post display.

For 'single' post displays you should be able to pass your single.php a ?rev=<post_id> parameter or even a ?rev=<revision_number> since WordPress saves post_name for revisions as <parent_post_id>-revision-<revision_number> with -<revision_number> not present for the first revision.

Those are my "comments and suggestions" as requested.

share|improve this answer
    
Looks like a good solution, only with some drawbacks. I understand that using the built in WP revision system could be beneficial on the DB side of things, but I'm also aware that revisions are made on every save and autosave done by wordpress meaning revisions could go into the hundreds on a post edited over a period of days. I'm now thinking it would probably be beneficial to branch/tag every major post revision that I would want to show. Could be difficult to do using the built in WP revisions? Again, just thoughts or ideas I'm looking for. –  davebowker Dec 3 '12 at 20:53
    
By default a post is auto saved no more than every 60 seconds, but you can change that. Revisions are not the same thing as autosaves. From what I can tell you get one autosave per post-- it is rewritten over and over. Revisions are saved when you save. I checked this by leaving a post open in the editor for while watching the 'revisions' with PhpMyAdmin. Revisions are created only when I intentionally save. –  s_ha_dum Dec 3 '12 at 21:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.