Created
April 11, 2019 09:04
-
-
Save DigitalEssence/3cd077949c096eba137d70185fdcc337 to your computer and use it in GitHub Desktop.
WordPress - PHP - Display posts dated in the future
This file contains hidden or 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
//Display Future Posts | |
function de_prevent_future_type( $post_data ) { | |
if ( $post_data['post_status'] == 'future' && $post_data['post_type'] == 'post' ) | |
/*Here I am checking post_type='post' , you may use different post type and if you want it | |
for all post type then remove "&& $post_data['post_type'] == 'post'" | |
*/ | |
{ | |
$post_data['post_status'] = 'publish'; | |
} | |
return $post_data; | |
} | |
add_filter('wp_insert_post_data', 'de_prevent_future_type'); | |
remove_action('future_post', '_future_post_hook'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment