From digging through /wp-includes/post.php, it looks like you may need to do the following:
- set your post_status to future
- set the post_date to when you want it published
- insert the post as your code shows
Run the following code after inserting the post
$time = strtotime( $postdate . ' GMT' );
wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) );
That is what wordpress uses internally to schedule future posts. check the following function for more information
check_and_publish_future_post( $post_id )
Related Posts:
- How do I check if I linked to a post before I delete it?
- How to check if post meta key exists or not in wordpress database
- disable password protected page for logged users
- Dynamically update post title in admin page
- How can I display 7 posts on the home page, but 9 posts on the subsequent pages?
- duplicate posts when trying to update a post using the wp_insert_post.
- Add custom field to all posts in specific category
- 404 error after publishing a post
- Hiding by default specific post status on backend list?
- How to edit layout of a particular post format?
- “Uncaught SyntaxError: Unexpected token
- Displaying Page Title on index.php
- Detect Post Type when publish_post is ran
- Showing Thumbnail from Previous and Next Posts
- WP_Query in functions.php overrides global $post object, even with wp_reset_query()
- How can I get all posts data from within a paginated search result?
- How to insert current date/time in the content of a post?
- How to automate filing a form as a user
- WP rest api returns 404 only when author param is used
- I want to query posts in monthly basis
- Reset/Reorder posts ID in the MySQL wp_posts table
- Encrypt / Decrypt Post Title and Details
- Will removing tags move Posts to Trash?
- Direct link to “New post” in specific category?
- JSON – Permission Error?
- Query get post,how to add comment box
- Is it possible to change post id for an already added menu item in WordPress?
- WP Bakery Load More Button loads the same posts
- How do I retrieve then print the currently viewed sub categories?
- WP Query – Posts Per Page not working in combination with category__in
- Apply a style for 4 blogs and another style for the next 4 blogs in wordpress blog page?
- How to convert contact form 7 submission to post after submission? [closed]
- How to render taxonomy in loop of custom post_type
- Posting blog entries in screenplay format
- Listing Specific Categories from Current Post with Depth
- get_the_category listing in hierarchial order
- How to automate featured posts number? [duplicate]
- Getting only the URL of the post thumbnail
- outputting posts’ taxonomies: cant get ‘get_the_taxonomies’ working
- Linking to pages/posts within the site
- Displaying posts that belong to a specific author
- Importing posts only – consequences?
- Add Post As a menu Item
- Query for first 3 posts to change the look and feel
- Getting blog pagination to work on page set as front page
- What is $post->pre_post_content exactly?
- Navigate through the posts using keyboard arrows
- unique post in “$args” of wp_query display more than one post
- New Posts and Pages Won’t Save
- Why excerpt is Displaying same in Random Posts list
- How can I add 2 buttons with shortcode
- Show posts on front page only
- Get featured image on hover of post title [closed]
- Showing posts for today and future
- Display 3 posts with different HTML markup using a loop
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- Moved to a new server, backup was a day old and missing 3 posts, anyway to recover them from old host?
- My post does not show up
- Hook save_post_cpt not triggered when custom fields are modified
- Set Default Post as Parent Child (Nested) Relation
- Display Current Posts Category (with the most posts)?
- Create a List of Widgets, where each widget holds three attributes
- How to automate creating pages on a hosted wordpress from a local set of folders?
- Filter posts by month (dropdown)
- How to limit wordpress the_excerpt() dynamically
- How to fetch courses in all languages in WordPress?
- Redirect old Posts URL to new URL
- Create a tree with categories with get_posts()
- WP posts using index.php instead of single.php
- Display simple html code in post
- How to display particular set of wordpress post on a webpage?
- Center crop the feature image
- Excluding tag Link from html tags in Post content
- Allow users to post their videos to my wordpress website?
- Display Custom Post Category Count & WordPress Category Count Using Shortcode
- Add Categories To Custom Post
- Display post on main page with thumbnail
- Get the category of post
- Display Posts by Categories
- Custom Single Post Type not referring to single-post-type.php File
- Problem with jQuery in post body?
- Custom template for different post types
- index.php is only displaying current month’s posts?
- How can I use the “Your latest posts” as a template?
- prevent same wordpress post title
- Remove duplicated posts in the loop if post has more than one category
- “Current” class on a singular page menu item with custom post types?
- get next/previous post name
- Get image paths from RSS feeds
- How do I display the next 3 posts in the sidebar?
- 2 tick boxes appearing below comments
- How can to use the players from the Media Widgets in the body of a post to play audio and video files
- Issue with wordpress pagination: last 2 posts show again on second page
- Extra Theme – Fit image inside of Featured Post Slider
- How can I display these posts in ascending order?
- Polylang – display one post into 3 categories with different lang [closed]
- How can I show the positive and negative comments for a same post separately?
- How to automatically convert a form with HTML link into post
- how to change background color of my all post
- WordPress Post Updating is Not Working