Title: Problem Updating Post With wp_insert_post
Last modified: August 20, 2016

---

# Problem Updating Post With wp_insert_post

 *  [kirkward](https://wordpress.org/support/users/kirkward/)
 * (@kirkward)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/problem-updating-post-with-wp_insert_post/)
 * I am trying to change the title and content of a post, while leaving its slug
   and ID unchanged. Simultaneously, I am trying to save options for use in the 
   updated post, or possibly save the modifications as metadata.
 * I don’t understand what I am doing, and it doesn’t save or overwrite the existing
   post.
 * Any suggestions on how to find and correct my error?
 * Here is my code …
 *     ```
       <?php 
   
       // Data to insert into post
         global $user_ID;
         $offer_3_post = array(
   
       // Identify the post that will be overwritten
       'ID' => $target_3_postid ,
       'post_category'  => array($target_3_cat_id),
   
       // Fille the new array with standard information
       'post_status' => 'publish',
       'post_date' => $target_3_post_date,
       'post_author' => $user_ID,
       'post_name' => $target_3_post_slug,
       'post_type' => 'post',
       'comment_status' => 'closed',
       'ping_status' => 'closed',
   
       // Fill the new array from the old
       'post_title' => $source_3_title,
       'post_content' => $source_3_content,
       'post_excerpt' => $source_3_excerpt,
       'to_ping' => $source_3_toping,
       'pinged' => $source_3_didping,
       'post_content_filtered' => $source_3_filteredcontent,
       'post_parent' => $source_3_parent,
       'guid' => $source_3_guid,
       'post_mime_type' => $source_3_mimetype
       );
       ?>
   
         <form action="" name ="offer_3_options" method="post">
         <b>Edit your offer description here.  Describe what you are willing to do as part of this offer. <br />(Your offer is limited to 250 characters.):</b>
         <br /><br />
         <textarea name="offer_3_t1" rows="5" cols="90" maxlength="250" ><?php echo get_option(offer_3_t1); ?></textarea>:
         <br /><br />
         <b>Enter the price or discount for your offer. <br />(Space is limited to 7 characters.):</b>
         <br />
         <input type="text" name="offer_3_n1" size="10" maxlength="7" value="<?php echo get_option(offer_3_n1); ?>">
         <br /><br />
         <b>Enter or edit the terms of any guarantee that you are offering with this special offer.  <br />(Your guarantee is limited to 150 characters.):</b>
         <br /><br />
         <textarea name="offer_3_t2" rows="5" cols="90" maxlength="150" ><?php echo get_option(offer_3_t2); ?></textarea>:<br />
         <br /><br />
         <b>Once you've made all your changes, click the button below to save your changes and then take a look at your home page and the offers page on your site to verify your edits and admire your work.</b>
         <br /><br />
         <center>
         <!-- These input fields and the submit button are copied from another page that actually "worked." -->
       	<input type="hidden" name="prev_offer_3" value="<?php $target_3_post_slug ?>" />
       	<input type="hidden" name="action" value="update" />
       	<input type="hidden" name="offer_3_options" value="offer_3_t1, offer_3_n1, offer_3_t2" />
       	<input type="submit" name="offer_3_options" value="Save Offer #3 Changes" />
         </center>
   
       <?PHP
   
         if(isset($_POST['offer_3_options'])) {
         // Update the post into the database
         wp_insert_post( $offer_3_post );
       }
       ?>
       ```
   

The topic ‘Problem Updating Post With wp_insert_post’ is closed to new replies.

## Tags

 * [isset](https://wordpress.org/support/topic-tag/isset/)
 * [save post](https://wordpress.org/support/topic-tag/save-post/)
 * [update post](https://wordpress.org/support/topic-tag/update-post/)
 * [wp_insert_post](https://wordpress.org/support/topic-tag/wp_insert_post/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 0 replies
 * 1 participant
 * Last reply from: [kirkward](https://wordpress.org/support/users/kirkward/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/problem-updating-post-with-wp_insert_post/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
