Title: Presave Function &#8211; Edit Post Title
Last modified: August 21, 2016

---

# Presave Function – Edit Post Title

 *  Resolved [unity3software](https://wordpress.org/support/users/unity3software/)
 * (@unity3software)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/)
 * In my custom POD settings, I have unchecked the Title field because my custom
   fields will ultimately determine what the title is.
 * At this stage, all of the records in list view are showing up as “Auto Draft.
   Obviously because it is hidden from the user. [Screen shots](https://dl.dropboxusercontent.com/u/106132126/Online%20Forum%20Picts/PODS_PostTitle.jpg)
 * How can I change the post_title during the ‘pre_save_pod_item’ action?
 * [https://wordpress.org/plugins/pods/](https://wordpress.org/plugins/pods/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Contributor [Josh Pollock](https://wordpress.org/support/users/shelob9/)
 * (@shelob9)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/#post-4585642)
 * What fields will determine the title?
 *  Thread Starter [unity3software](https://wordpress.org/support/users/unity3software/)
 * (@unity3software)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/#post-4585762)
 * My custom fields that I have defined via PODS. But to the question, how best 
   can I access the post_title field during ‘pre_save_pod_item’ action?
 *  Thread Starter [unity3software](https://wordpress.org/support/users/unity3software/)
 * (@unity3software)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/#post-4585763)
 * The POD is created from a custom post type
 *  Plugin Contributor [Josh Pollock](https://wordpress.org/support/users/shelob9/)
 * (@shelob9)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/#post-4585794)
 * Check out the docs for the pre_save filter:
    [http://pods.io/docs/code/filter-reference/pods_api_pre_save_pod_item_podname/](http://pods.io/docs/code/filter-reference/pods_api_pre_save_pod_item_podname/)
 * You should be able to set, in your pre_save filter, to set the post title value
   with `$pieces[ 'fields' ][ 'post_title' ][ 'value' ] = "WHATEVER_YOU_WANT_TITLE_TO_BE";`
 *  [Gattermeier](https://wordpress.org/support/users/gattermeier/)
 * (@gattermeier)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/#post-4585904)
 * How would that work? I tried this via functions.php, but I am still getting the
   same “Auto Drafts” for all items.
 *  Thread Starter [unity3software](https://wordpress.org/support/users/unity3software/)
 * (@unity3software)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/#post-4585911)
 * Josh, _pods\_api\_pre\_save\_pod\_item_ does not work because _$pieces[‘fields’]_
   only refers to custom meta fields. The default post fields such as _‘post\_title’_
   are only found in: _$pieces[‘object\_fields’]_. However, these only appear to
   be field descriptors because there is no _‘value’_ property to any of these fields.
 * Gattermeier, here is my current hack for this POD bug. Hook into the _‘wp\_insert\
   _post\_data’ filter_, which runs for every post add/edit/update. To access the
   metadata, use: _$postarr[ ‘pod\_meta\_%my\_meta\_name%’]_. By the way, this filter
   runs BEFORE _pods\_api\_pre\_save\_pod\_item_.
 *     ```
       function wp_pre_save( $data , $postarr ) {
           //$data['post_title'] = $postarr['pods_meta_width'].'x'.$postarr['pods_meta_length'];
           if ($data['post_type'] == 'metal_building') {
               $width = $postarr['pods_meta_width'];
               $length = $postarr['pods_meta_length'];
               if (!empty($width) && !empty($length)) {
                   $data['post_title'] = $data['post_name'] = $width.'x'.$length;
               }
           }
           return $data;
       }
   
       add_filter( 'wp_insert_post_data', array($this,'wp_pre_save'), '99', 2 );
       ```
   
 *  [Gattermeier](https://wordpress.org/support/users/gattermeier/)
 * (@gattermeier)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/#post-4585960)
 * Thank you unity3software. However, trying to add this has a peculiar effect. 
   Suddenly I am not able anymore to save any post, yet alone publish. The functionality
   seems limited to “submit for review” for all content types, including posts and
   pages.
    Any idea?

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Presave Function – Edit Post Title’ is closed to new replies.

 * ![](https://ps.w.org/pods/assets/icon.svg?rev=3286397)
 * [Pods - Custom Content Types and Fields](https://wordpress.org/plugins/pods/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pods/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pods/)
 * [Active Topics](https://wordpress.org/support/plugin/pods/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pods/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pods/reviews/)

## Tags

 * [auto draft](https://wordpress.org/support/topic-tag/auto-draft/)
 * [post_title](https://wordpress.org/support/topic-tag/post_title/)

 * 7 replies
 * 3 participants
 * Last reply from: [Gattermeier](https://wordpress.org/support/users/gattermeier/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/presave-function-edit-post-title/#post-4585960)
 * Status: resolved