ACF post meta fields’ (custom fields) values are not visible on draft preview – before you publish a post. If you want to preview a post/page, before you want to publish, this is going to cause headache. If you already did not know about this issue, you would be lost entirely, trying to find out the problem!
There is a quick hack to prevent this, by unsetting the preview mode. This is probably not the best option, but can solve the headache!
function careless_hack_preview() {
$post_types = array ( 'post', 'page' );//add your custom post types, if you need to
global $post;
if ( !in_array( $post->post_type, $post_types ) ) {
return;
}
if(isset($_GET['preview'])){
unset($_GET['preview']);
}
}
add_action( 'wp', 'careless_hack_preview' );
Code goes in the functions.php
file of your active theme.