WordPress as a web app – always auto-save post and meta data

Set custom autosave interval

Just define it in your wp-config.php file

// Allow revisions
define( 'WP_POST_REVISIONS', true);
// Set number of ms
define( 'AUTOSAVE_INTERVAL', 300 );

Note that this means that you’ll get a lot of queries and post revisions. Therefore you should also add a max. number of revisions to not fill your posts table with stuff you don’t need.

// You need to calculate this very precise.
// If someone needs a long time to write the document, old revisions get trashed
define( 'WP_POST_REVISIONS', 20 );

Query the ‘revision’ post status

You’ll have to do this via a custom plugin that hooks into 'plugins_loaded' to intercept the main query posts clauses.

function intercept_post_clauses( $pieces, $class )
{
    $pieces['where'] = str_replace( ".post_status="publish"", ".post_status="revision"", $pieces['where'] );

    return $pieces;
}
function mod_post_clauses()
{
    add_filter( 'posts_clauses', 'intercept_post_clauses', 20, 2 );
}
add_action( 'plugins_loaded', 'mod_post_clauses' );

Note: This code is not tested, but written directly in here.


Note: I don’t think that this is an good idea. The problem is that there won’t be any real revision system left. When setting the number of revisions too high, the post table will instantly have hundreds of redundant posts. When setting it too low, there’ll be no real revision left, as you loose your old revision after

XY ms × # of revisions.

So if someone stays longer on a post edit screen than the calculated time, the revisions will simply be lost.