Post Not Insert into database on Cron Job
-
Hi,
Post Not Insert into the database on Cron Job.Cron executing but post could not be inserted to database Below my code
function api_call() { $post = array( 'post_author' => 1, 'post_content' => $productDetails->description, 'post_status' => $productDetails->status, 'post_title' => $productDetails->title, 'post_parent' => $productDetails->parent_id, 'post_type' => "product", ); $post_id = wp_insert_post( $post, $wp_error ); } add_action( 'init', 'register_daily_revision_delete_event'); function register_daily_revision_delete_event() { wp_schedule_event( time(), 'daily', 'api_call' ); } add_filter( 'cron_schedules', 'add_custom_cron_intervals', 10, 1 ); function add_custom_cron_intervals( $schedules ) { // $schedules stores all recurrence schedules within WordPress $schedules['ten_minutes'] = array( 'interval' => 300, // Number of seconds, 600 in 10 minutes 'display' => 'Once Every 5 Minutes' ); // Return our newly added schedule to be merged into the others return (array)$schedules; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Post Not Insert into database on Cron Job’ is closed to new replies.