I don’t know why you are loading WordPress by including the core files, there should be something wrong at that point.
Anyway, to schedule an event, you can use wp_schedule_single_event
. This function accepts 3 arguments:
wp_schedule_single_event( $timestamp, $hook, $args );
In your case, you can wrap wp_insert_post
in a function, and then call it when the time arrives:
// Use this instead of wp_insert_post
wp_schedule_single_event( 'SET THE TIME HERE', 'schedule_my_post' );
// Add an action that runs the function
add_action( 'schedule_my_post','publish_my_post' );
// Now, do the actual publish
function publish_my_post($args){
wp_insert_post($args);
}
Done.
Related Posts:
- How to prevent posts from being published too close to each other?
- How to switch wordpress post status between publish and schedule in MySQL?
- add action only on post publish – not update
- Is it possible to Schedule Attachments in WordPress?
- Elegant way to include only published posts with get_objects_in_term()?
- Immediately published posts are scheduled and published 2 hours later
- WordPress plugin to publish to multiple remote WordPress blogs
- Post publish only hook?
- Publish pending article from front end with a button?
- How to add a “publish” link to the quick actions
- How to limit user to publish post per day and per role?
- When a user creates a post (pending), send a confirmation link that allows them to publish
- In what sequence are the hooks fired when a post is “published”?
- Restrict the Number of Posts an Author can Publish (over time)?
- Add javascript when post is published
- featuring old articles without messing up with the archive
- Publish posts only after the condition is met
- Hiding by default specific post status on backend list?
- All WordPress scheduled posts are being published immediately
- Detect Post Type when publish_post is ran
- How can I display a specific user’s first published post?
- Does WordPress remove draft status automatically?
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- Prevent post from being published if no category selected
- Send email to user that his post has been rejected
- Unschedule a post
- Limit number of posts a user can make per minute?
- Every possible way to get data (posts) from WordPress
- publish_post conflicts with save_post
- Notification to Admin or Author upon new post [duplicate]
- What differences are there between a Privately Published post and a Draft post?
- How to run a function when post is edited or updated using publish post action?
- How can I create custom button in post.php
- Disabled wp-cron, set up system cron but still have missed schedule posts
- How to rename “Publish” metabox title in post screen
- count the total number of comments the user has received for his published posts
- Automatically Updating Publish Date Bug
- How can I schedule a PAGE to go live at a future date/time?
- How to give capability (publish contributors posts) to author role?
- Print a message if excerpt is empty after posts have been publish/update!
- Check if checkbox is marked on publish/update post
- Decide user that can publish a post
- Update Modified date when scheduled posts get published
- Prevent scheduled post being published if date/time is past current date/time
- Calling Different Custom Post Timestamps in a table
- Copy post to separate database with “add_action(….)”
- Do action on publish or update?
- transition_post_status hook doesn’t have any POST data when publish with Gutenberg [closed]
- How do I manage my users post before publish?
- do more action after I publish a post
- Assign published posts to another user automatically
- Display password protected posts to logged in users
- Stop wordpress from creating empty/null entries
- WordPress bulk category select when publishing post
- How can I tell if a post has been published at least once?
- Send email for pending post
- Post: how to set created date after post has been published [closed]
- Add delay to publish post
- Scheduling posts via sql
- Publish a Silent Post without updating Feed
- How can my plugin display a populated new post window
- How to set a Post’s default visibility to ‘Private’ in Gutenberg?
- WordPress doesn’t save or publish new posts
- Hook when post is set from published to draft?
- Send email to user when I publish a new post
- My posts are getting to Auto draft when I try to Publish
- How to publish a post if condition is met?
- WordPress get tags in “publish_post” hook
- How publish post from pending status
- post is not showing more than 3949 words
- Bulk Post update_post_meta
- I want to send push notification just after publish a new post
- How to prevent people from seeing an attachment to a scheduled post that’s released in future?
- How to Test a Blog Post for Update vs. Publish Status — Unique
- How to handle a post before publishing?
- Return All Post from publish to draft [duplicate]
- I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in publish
- Action while post is being published
- How can add custom commands in post-new.php in wordpress
- How to enqueue scripts depending on post formats?
- How to add a custom field after wp post
- How to prevent WordPress from updating the modified time?
- Dynamic carousel on individual posts
- Remove all links in post content
- I get this error message when I try to add a module to a course on my website using Sensei plugin
- Get all comments of author’s posts
- Adding bootstrap classes to video shortcodes
- posts_per_page returning only one post
- How to change the order of elements within a post?
- Right align a youtube video
- How do I fix broken links to images in imported posts’ post_content?
- Get Category in save_post Hook
- Is it possible to query a category with specified posts?
- Add caption to thumbnails in content
- How to retrieve a post by inputing the url in a custom field and displaying it on an options page
- Text editor has problem with having ” in a post
- Getting posts from multiple users?
- Stripping tag from elements in post
- Even/Odd every two posts
- I cannot see the pagination in /wp-admin posts page