Skip to content

Instantly share code, notes, and snippets.

@the-sufi
Last active August 25, 2020 15:09
Show Gist options
  • Save the-sufi/8a33887307136431295784339b884ec6 to your computer and use it in GitHub Desktop.
Save the-sufi/8a33887307136431295784339b884ec6 to your computer and use it in GitHub Desktop.
ACF fields don't show up when previewing draft posts. This is an ugly hack to try and overcome that situation.
<?php
/**
* ACF fields don't show up when previewing draft posts. This is an ugly hack to try and overcome that situation.
*/
function dctit_hack_preview() {
$post_types = array ( 'post', 'page' );//add/edit/delete post types as needed
global $post;
if ( !in_array( $post->post_type, $post_types ) ) {
return;
}
if(isset($_GET['preview'])){
unset($_GET['preview']);
}
}
add_action( 'wp', 'dctit_hack_preview' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment