8

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
  • 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. Commented Dec 21, 2017 at 23:20

1 Answer 1

1

Are you using or do you have gutenberg enabled? If so is it up to date?

If not can you please let us know what theme if any and what editor if any.

There is a well known bug that seems to show it's face if you are using gutenberg. It was meant to have been fixed (please make sure your wordpress and gutenberg are up to date) however there are recent reports this could still be an issue:

Original report and confirmed bug here: https://github.com/WordPress/gutenberg/issues/11280

Confirmed bug fixed here: https://github.com/WordPress/gutenberg/pull/11409

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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