1 comment

  1. The following code will prevent your meta data from saving on preview but You won’t be able to preview published posts with your metadata. Honestly I’m trying to figure out this situation myself :/

    <?php // In your save metabox data function, near the top...
    if (isset( $_POST['wp-preview'] ) && 'dopreview' == $_POST['wp-preview'] ) {
      if(get_post_status($post_id) == 'publish'){
        return; // This way we can still preview draft / scheduled posts
      }
    }
    

    Honestly, I’d use this code and set your post briefly to draft or private while editing / previewing and publish them as normal when you’re done.

Comments are closed.