title: How to insert post with cron job in Wordpress
body: <p>I want to make a plugin that that creates a new posts every 30 minutes using cron job.
  I have already create a new interval for my cron job.
  I think tha problem is in inserting a new post. I am not sure can you help me?</p>
  
  <pre><code>&lt;?php
  /*
  Plugin Name:
  Description:
  Version: 1.0
  Author:
  */
  
  add_filter('cron_schedules', 'new_interval');
  
  // add once 30 minute interval to wp schedules
  function new_interval($interval) {
      $interval['minutes_30'] = array('interval' =&gt; 30*60, 'display' =&gt; 'Once 30 minutes');
  
      return $interval;
  }
  
  function InitiateMyCron() {
      if (!wp_next_scheduled('MyCronEvent')) {
          wp_schedule_event(time(), 'minutes_30', 'MyCronAction');
      }
  }
  
  function MyCronAction() {
      //do my cron every 30 minutes
      $new_post = array(
      'post_title' =&gt; 'Cron job New Post',
      'post_content' =&gt; 'Lorem ipsum dolor sit amet...',
      'post_status' =&gt; 'publish',
      'post_date' =&gt; date('Y-m-d H:i:s'),
      'post_author' =&gt; 1,
      'post_type' =&gt; 'post',
      'post_category' =&gt; array(6, 2)
      );
  
      $post_id = wp_insert_post($new_post);
  }
  
  ?&gt;
  </code></pre>
  
  <p>what am I doing wrong?</p>
  
  <p>Thank you in advance.</p>