• Hi, we need to be able to provide a view of what information was contained on our website at any given point in time in case there’s an issue with a customer complaint. Is it possible to retrieve a view of page/post content depending on date? I’ve tried WP plugin VersionPress but its not suitable for production. Is this functionality possible?
    rm

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @raymallon,

    WordPress includes a built-in feature for Revisions, which tracks every change made to your post or page content over time.

    You can access it directly on the Post or Page Editor on the sidebar at the right of the screen. If you need support for Custom Post Types, just enable it when it’s registered.

    If you’re using a block theme, this will track all content from the website.

    For classic themes, you could install a backup plugin or add something like Simple History or Activity Log to track changes in widgets, settings, media, etc.

    To track files via Git, you can use Revisr or Gitium – or create a regular Git repository on your wp-content folder if you control your server and need a more granular setup.

    Hello @raymallon,

    To achieve version control of page or post content based on a specific date in WordPress, you can use the built-in Revisions feature. WordPress automatically saves revisions of pages and posts, allowing you to restore or view past versions based on the date. However, to retrieve and display a specific revision programmatically, you can use the following solution:

    Use wp_get_post_revisions() to retrieve past revisions of a post or page based on the ID.

    Add this function to your functions.php file to display the content of a specific revision by date:

    function get_revision_by_date( $post_id, $revision_date ) {
    $revisions = wp_get_post_revisions( $post_id );
    foreach ( $revisions as $revision ) {
    if ( $revision->post_date <= $revision_date ) { return apply_filters( ‘the_content’, $revision->post_content );
    }
    }
    return ‘No revision found for this date.’;
    }
    To call this function, pass the post ID and the desired date (e.g., get_revision_by_date(123, ‘2023-10-01 00:00:00’);).
    This retrieves and displays the content for the closest revision on or before the specified date.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.