How to Publish a WordPress Post with a Future Date but Display Now

You may want to publish your WordPress post just right now but post date will be a future time. By default WordPress doesn’t have such option. Here I will show you a very simple trick to do this.
WordPress Clock
WordPress has an option to publish any post in a future date/time. It is called future-post/Scheduled-post. You can set future date/time for a post from the post edit panel just above the publish button. After setting up the post date with a future time the publish button will be changed into Schedule button. You may finish your posting by clicking on Schedule button. Your post will be saved for future publishing, post_type field will be set by ‘future‘ instead of ‘publish‘ . And it will not be displayed to visitors on your site fornt-end. WordPress displays which posts those have post_type=’publish’. You may manage your scheduled posts from dashboard by using my plugin “WP Scheduled Posts“. When your given future date will come then post will be published automatically and appeared to all. But if you want you publish your post immediately right now and post date will set as a future date, what to do then? WordPress doesn’t have any default solution for this situation. But WordPress is very flexible and customizable CMS, It gives us a lot of filter and action hooks to fire our custom function on any point of the script. I made a very simple PHP codes to have this feature with an WordPress blog. Put my following codes in your theme functions.php. I have updated my plugin “WP Scheduled Posts” by including this feature. You can use that plugin instead of editing functions.php.

<?php
function onetarek_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', 'onetarek_prevent_future_type');
remove_action('future_post', '_future_post_hook');
?>

These codes prevents to create post_type=’future’ and publish the post immediately though the post date set for a future time. WordPress will not to thing about post date on publishing. It force WordPress to publish the post with future timestamps.