title: Wordpress: wp_insert_post() firing multiple times
body: <p>I'm building a simple WP plugin that's supposed to create a new post and save some meta for the post. I created a function with the functionality and for the time being I hooked it to the 'init' event to check if it works.</p>
  
  <pre><code>add_action( 'init', 'my_func' );
  
  function my_func() {
  
      $my_post = array(
          'post_title'    =&gt; 'Some Post Title',
          'post_name'     =&gt; 'some-post-title',
          'post_type'     =&gt; 'custom-post-type',
          'post_status'   =&gt; 'publish'
      );
  
      $inserted_post_id = wp_insert_post($my_post);
  
      if($inserted_post_id != 0) {
          add_post_meta($inserted_post_id, 'some-key', 'some-value');
          add_post_meta($inserted_post_id, 'some-other-key', 'some-other-value');
          echo 'SUCCESS';
      } else {
          echo 'ERROR';
      }
  }
  </code></pre>
  
  <p>Now, whenever I reload the admin page, I get the 'SUCCESS' message echoed out, and I also get 4-6 new post called 'Some Post Title', and 4-6*2 new entries in the postmeta table. The 'SUCCESS' message echoes only once, meaning the function runs only once, still I get the data inserted to the database multiple times. What am I doing wrong?</p>