acf_revisions::wp_preview_post_fields
wp_preview_post_fields
This function is used to trick WP into thinking that one of the $post's fields has changed and will allow an autosave to be updated. Fixes an odd bug causing the preview page to render the non autosave post data on every odd attempt
Method of the class: acf_revisions{}
No Hooks.
Returns
$fields.
Usage
$acf_revisions = new acf_revisions(); $acf_revisions->wp_preview_post_fields( $fields );
- $fields(required)
- .
Changelog
| Since 5.1.0 | Introduced. |
acf_revisions::wp_preview_post_fields() acf revisions::wp preview post fields code ACF 6.0.4
function wp_preview_post_fields( $fields ) {
// bail early if not previewing a post
if ( acf_maybe_get_POST( 'wp-preview' ) !== 'dopreview' ) {
return $fields;
}
// add to fields if ACF has changed
if ( acf_maybe_get_POST( '_acf_changed' ) ) {
$fields['_acf_changed'] = 'different than 1';
}
// return
return $fields;
}