Skip to content

Instantly share code, notes, and snippets.

@yrosen
yrosen / wp-preview-changes-meta-fix.php
Last active December 21, 2015 01:59 — forked from roborourke/wp-preview-changes-meta-fix.php
Fix is_preview() to work properly when updating in admin AND when previewing in front end.
<?php
// post meta for previews
class wp_preview_meta {
private $doing_preview = false;
public function __construct() {
add_filter( 'add_post_metadata', array( $this, 'add' ), 10, 5 );
add_filter( 'update_post_metadata', array( $this, 'update' ), 10, 5 );