Skip to content

Instantly share code, notes, and snippets.

@ChrisLTD
Created May 8, 2014 16:22
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ChrisLTD/892eccf385752dadaf5f to your computer and use it in GitHub Desktop.
Save ChrisLTD/892eccf385752dadaf5f to your computer and use it in GitHub Desktop.
Fix so you can preview ACF field changes in Wordpress admin
<?php
/*
Debug preview with custom fields
Taken from: http://support.advancedcustomfields.com/forums/topic/preview-solution/
See also: http://support.advancedcustomfields.com/forums/topic/2nd-every-other-post-preview-throws-notice/
*/
add_filter('_wp_post_revision_fields', 'add_field_debug_preview');
function add_field_debug_preview($fields){
$fields["debug_preview"] = "debug_preview";
return $fields;
}
add_action( 'edit_form_after_title', 'add_input_debug_preview' );
function add_input_debug_preview() {
echo '<input type="hidden" name="debug_preview" value="debug_preview">';
}
@JakedUp
Copy link

JakedUp commented Aug 3, 2016

This was working for quite a while, but I just noticed it's no longer working. Any workarounds?

@paperrobots
Copy link

Just tried it, seems to still be working.

@anubhavbhatt
Copy link

Just tried this, its not working with the WordPress 5.3.2 and ACF PRO Version 5.8.3. Can you please provide the updated solution for this. On preview mode ACF fields are not changed.

@JacobDB
Copy link

JacobDB commented Nov 2, 2020

@anubhavbhatt running in to this issue as well, did you figure out a solution?

@Chaoste
Copy link

Chaoste commented Nov 4, 2020

Here, you find the latest solution to this bug by CamiloAPR. Worked for me but this is still an open ticket so one should always look into this ongoing forum thread ;)

@valeriedore
Copy link

I searched for this answer for a while!
I finally found it. No code in the function required :

Enabling Revisions for the Custom post types solved this issue!

Ref : https://support.advancedcustomfields.com/forums/topic/preview-changes-not-working-for-acf-cpt/

@alireza-ebrahimkhani
Copy link

Here, you find the latest solution to this bug by CamiloAPR. Worked for me but this is still an open ticket so one should always look into this ongoing forum thread ;)

Awsome

@gavin310
Copy link

I searched for this answer for a while! I finally found it. No code in the function required :

Enabling Revisions for the Custom post types solved this issue!

Ref : https://support.advancedcustomfields.com/forums/topic/preview-changes-not-working-for-acf-cpt/

Thanks! Not having revisions enabled was my issue! I use WP Engine and they disable revisions by default (you have to ask their tech support to enable it). Then you need to enable revisions for each of your post types as well.

@amrikarisma
Copy link

amrikarisma commented Jan 24, 2023

Thank you. In 2023 it still works.

@codeandvisual
Copy link

This appears to no longer work as of June 2023. WP 6.2.2, ACF Pro 6.1.6. Revisions enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment