title: Create custom post type whenever another custom post type is created
body: <p>I'm trying to add a feature to my Wordpress website, that every time I add a post (custom post type), another post (different custom post type) is created.</p>
  
  <p>I have tried adding an action in my function file but it does not seem to work.</p>
  
  <p>functions.php</p>
  
  <pre class="lang-php prettyprint-override"><code>function add_notification($post_id) {
      global $wpdb;
      $post_type = get_post_type($post_id);
      if($post_type == 'exercises'){
          $title = "BLA";
          $post_id_new = wp_insert_post(
              array(
                  'comment_status'    =&gt;  'closed',
                  'ping_status'       =&gt;  'closed',
                  'post_title'        =&gt;  $title,
                  'post_status'       =&gt;  'publish',
                  'post_type'     =&gt;  'notification'
              )
          );
      }
  }
  add_action('publish_post', 'add_notification');
  </code></pre>
  
  <p>I have also tried it with other hooks like new_to_publish and publish_post</p>
  
  <p>With that I was expecting to have a new post (notification) when I add an exercise post.</p>
  
  <p>I think it's something silly I'm forgetting but it's been like 3 days that I'm stuck in this problem.</p>