Question

Setting:

three open Tabs in browser:

Tab 1: Admin edit post

Tab 2: Frontend view of that post in "editing mode"

Tab 3: Frontend view in "non-editing" mode (default request)

I edit the post on Tab 2 (frontend editing) and save it via AJAX (via wp_update_post). When I refresh this Tab, or Tab 3, I can see the changes.

But when I refresh Tab 1 (WP Backend edit-posts page), I see the old content in the editor, but a new revision was added. When I hard-refresh that page, it works as expected. (This might be very confusing to editors)

So why does it work only on hard refresh, but not on normal refresh? Is there any kind of caching active? (couldn't find anything in the codex)

Simlified Ajax save action:

function save_page() {
    $postID = (int)$_POST['postID'];
    $content = $_POST['content'];

    $my_post = array(
        'ID'           => $postID,
        'post_content' => $content
    );

    wp_update_post( $my_post );

    exit;
}

Edit:

In the Backend, on normal refresh:

    global $post;
    echo "<pre>";
    print_r($post->post_content);
    echo "</pre>";

prints a different result content than shown in the editor.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top