title: wp_after_insert_post not triggering
body: <p>I am trying to send an email after a new post has been created. It needs to be sent after the creation of the post, because I want to include the post category in the email. <code>wp_after_insert_post</code> does not seem to work, as no email is sent. I have tried using the same code with the <code>publish_post</code> hook instead, which does send an email correctly, but I am then unable to use the category name in the email.</p>
  <pre><code>function new_post_email( $post_id ) {        
      $categories = get_the_category( $post_id );
      $subject = $categories[0]-&gt;name;
  
      $sent = wp_mail($to = 'my@email.com', $subject, $message = 'Test message');
  };
  add_action( ' wp_after_insert_post', 'new_post_email');
  </code></pre>
  <p>Is there any solution for this? Thanks in advance</p>