title: Update wordpress post from front-end (using acf)
body: <p>I am making front end admin for users to add/edit their posts. I already made post add form and it works, but edit form doesnt work.</p>
  
  <p>functions.php</p>
  
  <pre><code>function add_new_post( $post_id )
  {
      if( $post_id == 'new' ) {
          // Create a new post
          $post = array(
              'post_title' =&gt; $_POST["fields"]['field_52c810cb44c7a'],
              'post_category' =&gt; array(4),
              'post_status'  =&gt; 'draft',
              'post_type'  =&gt; 'post'
          );
  
          // insert the post
          $post_id = wp_insert_post( $post );
  
          return $post_id;
      }
      else {
          return $post_id;
      }
  }add_filter('acf/pre_save_post' , 'add_new_post' );
  </code></pre>
  
  <p>index.php</p>
  
  <pre><code>&lt;div id="updateform-&lt;?php the_ID(); ?&gt;" class="collapse"&gt;
      &lt;?php
      echo get_the_ID();
      $args = array(
          'post_id' =&gt; get_the_ID(), // post id to get field groups from and save data to
          'field_groups' =&gt; array(31), // this will find the field groups for this post (post ID's of the acf post objects)
          'form' =&gt; true, // set this to false to prevent the &lt;form&gt; tag from being created
          'form_attributes' =&gt; array( // attributes will be added to the form element
              'id' =&gt; 'post',
              'class' =&gt; '',
              'action' =&gt; get_permalink( get_the_ID() ),
              'method' =&gt; 'post',
          ),
          'return' =&gt; add_query_arg( 'updated', 'true', get_permalink() ), // return url
          'html_before_fields' =&gt; '', // html inside form before fields
          'html_after_fields' =&gt; '', // html inside form after fields
          'submit_value' =&gt; 'Update', // value for submit field
          'updated_message' =&gt; 'Post updated.', // default updated message. Can be false to show no message
      );
      acf_form( $args );
      ?&gt;
  &lt;/div&gt;
  </code></pre>