2

With the latest version of WordPress, how can we publish revisions of a post, in addition to showing the latest post?

I want my front end users to see multiple versions of the same post. The same post is going to change "some" of its content every friday. All weekly versions will then be compared by non-administrators (ie managers and directors) at some point every month.

My goal is to make it as easy as possible for a public user to review revisions.

There doesn't appear to be a plugin concept for this. Can I modify the internal revisions tool to accomplish something like this?

Many thanks!

1

I suggest you look at https://codex.wordpress.org/Function_Reference/wp_get_post_revisions

<?php
            // Lets get the revisions of the given $post we are accessing by ID ( you are probably going to want to limit your internal revision count for this

            $revisions =  wp_get_post_revisions($post->ID);
            // lets just do some formatting here ( your post html content is going to display normally but lets get the var_dump to look decent
            echo '<pre>';
            //  print the $revisions variable to look at the internals
            var_dump($revisions);
            echo '</pre>';

            // from here i would dig into iterating over the revisions array.
            ?>

using the above code inside your loop should get your started to see what kind of data you can return from wp_get_post_revisions(). You are going to need to do some searching on the post_date portion or look at the array key and sort by the integer and push to a custom array where key matches count() to return only the most recent post revision. This query will be huge so i sincerely suggest you limit your wordpress installs revision count.

0

That's an interesting idea. There are, of course, manual ways to do it - e.g. cloning the post, making your changes, giving it a new 'date related?' slug etc., but it sounds like you want something more automated. One thought is whether there are any A/B (or A/B/C/D) split testing plugins (or theme options - Divi?) that allow you to do what you wanted.

One other thought - how about putting the main post content into a tab element, and then copying / pasting / editing the changed content into a new tab at the end of each week? Then, your default post open view would be for the current content, and the user would be able to click on the tabs to view previous week content.

You'll need to take care with this sort of thing if you have any SEO ambitions, as you will end up with a lot of duplicated content across your site.

  • But you know that WordPress already stores revisions for posts, right? – Krzysiek Dróżdż Jul 27 '18 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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