title: Wordpress PHP warning: Creating default object from empty value in wp-admin\includes\post.php on line 627
body: <p>I am using Wordpress 4.2.2, Xampp installation in windows with PHP 5.6.8</p>
  
  <p>I have added the following function to my theme's functions.php to automatically set the title of the post type 'departure':</p>
  
  <pre><code>function custom_title() {
      if ($_POST['post_type'] == 'departure') :
          $post_title = 'Departure-'.$_POST['post_ID'];
          return $post_title;
      endif;
      }
   add_filter ( 'title_save_pre', 'custom_title' );
  </code></pre>
  
  <p>Title setting for the custom post type "departure" works fine. But when I try to add a new wordpress standard post (i.e. post_type = post) I get the following error:</p>
  
  <p><em>Warning: Creating default object from empty value in wp-admin\includes\post.php on line 627</em></p>
  
  <p>Line 627 is as follows:</p>
  
  <pre><code>/**
   * Filter the default post content initially used in the "Write Post" form.
   *
   * @since 1.5.0
   *
   * @param string  $post_content Default post content.
   * @param WP_Post $post         Post object.
   */
  $post-&gt;post_content = apply_filters( 'default_content', $post_content, $post );
  </code></pre>
  
  <p>All the other post types (i.e. custom types and wordpress standard page) work fine. By dumping $_POST data in a logfile I have seen, that for all the working post-types an empty array (i.e. array()) is passed as $_POST data. This does not happen with the "post" post type.</p>
  
  <p>If I comment the function in functions.php, an empty array is sent as $_POST data when adding a new "post" post type, and the problem disappears.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks</p>