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 the post date will be a future time. By default, WordPress doesn’t have such an option. Here I will show you a very simple trick to do this.
WordPress Clock
WordPress has an option to publish any post at a future date/time. It is called future-post/Scheduled-post. You can set a 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 the Schedule button. You may finish your posting by clicking on the 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’s front end. WordPress displays which posts those have post_type=’publish’. You may manage your scheduled posts from the dashboard by using my plugin “WP Scheduled Posts“. When your given future date will come then the post will be published automatically and appeared to all. But if you want to publish your post immediately right now and the post date will be set as a future date, what to do then? WordPress doesn’t have any default solution for this situation. But WordPress is a 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 code to have this feature with a WordPress blog. Put the following code 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.

This code prevents the creation of post_type=’future’ and publishes the post immediately though the post date is set for a future time. WordPress will not think about the post date on publishing. It forces WordPress to publish the post with future timestamps.

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');



  1. Hi,

    thank you for this post. Is it possible to have this feature only for specific post categories?

    So Maybe i have to put something for more in here?
    if ( $post_data[‘post_status’] == ‘future’ && $post_data[‘post_type’] == ‘post’ )

    Like $post_data[‘post_category’] == ‘specific category’

    Sorry i´m a Beginner 🙂

    Thank you!


    1. Yes , you can do that. But in that case you have to add new parameter to the function, Here I am using one parameter but wp_insert_post_data hook sends to parameters to the callback function.
      `post_category` is not exists in post_data array. That exists in the second parameter $postarr . So add new parameter to the callback function and check category in $postarr array.


  2. Super helpful! Thanks so much for posting this.

    I’m using a custom post type for events and need to be able to show upcoming events, I didn’t want to have to start all over again and this is exactly what I needed!


  3. Worked perfectly.

    I also needed to publish future events for an events calendar.

    Thank you!


  4. I see an option saying “Show Publish Post Immediately Button” and I enabled it. However I didn’t see the “checkbox” or button appeared in my post editor. I am using WP 5.2.4


  5. I’ve tried adding your code to my functions.php file as well as installing WP Scheduled Posts, nothing seems to work. I have all categories allowed, (although I want to specify one category) and type is posts. I’ve also tried a few other solutions from Stack Exchange with no luck. Something in my theme must be overriding, although I don’t see any settings to determine whether or not future posts are showing.

    There should be an event on the homepage that dated for May 16th.



  6. Worked beautifully!

    I needed to publish post as future events but did not like the way The Events Calendar show the posts.

    The Events Calendar don’t work either with “Display Posts”.

    Thank you for posting this, Very helpful!


  7. There is a way to do the same with comments? Its very important to me. Thx


  8. Your code is shit, full of errors


    1. Hi, the code became buggy in the Gutenberg age. The old syntax highlighter was not working perfectly. I have updated my code.


  9. I’d love to use your script but have a problem.

    68 function onetarek_prevent_future_type( $post_data ) {
    69    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'”
    70    {
    71       $post_data[‘post_status’] = ‘publish’;
    72    }
    73    return $post_data;
    74 }
    76 add_filter(‘wp_insert_post_data’, ‘onetarek_prevent_future_type’);
    77 remove_action(‘future_post’, ‘_future_post_hook’);

    I’ve tried adding this code in functions.php but it gives an error:
    Your PHP code changes were rolled back due to an error on line 70 of file wp-content/themes/Extra/functions.php. Please fix and try saving again.

    syntax error, unexpected ‘    ‘ (T_STRING)

    I’m using wordpress 6.1.1

    Do you have a solotion for this?


    1. Hi, You copied the PHP code snippet with line numbers. Copy the code perfectly and use that.


Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.