6

How can I have the 'Preview Changes' working for custom meta boxes? For instance, I just want to test/ preview some text in a custom meta box but I don't want to save/ update because that post/ page is already gone live.

eg:

    $post_id = $post->ID;

    $meta = get_post_meta( get_the_ID(), 'meta_tile1_text', TRUE );
    var_dump($meta);
    ?>
    <p><?php echo $meta;?> </p>

This only works when I click 'Update' button in the backend. But it does not when I click 'Preview Changes'. I have to save the 'preview' text in order to see it.

Is it possible?

  • 1
    Current WP flow allows full preview (with updated fields without saving) only for posts in status 'draft'. Published posts do not have full preview. Additional code can be applied with a hook but this code will be complicated. – Serkan Algur Dec 21 '17 at 23:20

Your Answer

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

Browse other questions tagged or ask your own question.