Last active
August 25, 2020 15:09
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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