Title: wp_insert_post_data, Publishing failed
Last modified: January 31, 2019

---

# wp_insert_post_data, Publishing failed

 *  [Kru-x](https://wordpress.org/support/users/mrkrux/)
 * (@mrkrux)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/wp_insert_post_data-publishing-failed/)
 * Hi,
 * I have a post type that I convert all titles to uppercase with below filter, 
   works with the post type and it worked before Gutenberg, but now the Gutenberg
   editor wont save any pages, post until I remove the filter. AND I dont understand
   why, any ideas?
 * This is what I use:
 * /**
    * Change title to upper case on save */ add_filter( ‘wp_insert_post_data’,
   function( array $data ) {
 *  $screen = get_current_screen();
 *  if ( “my_custom_post” == $screen->post_type ){
    // list of words not to change
   $protected_words = [ ‘SQL’, ‘CSS’, ‘BBC’ ];
 *  if ( empty( $data[‘post_title’] ) )
    return $data;
 *  $words = explode( ‘ ‘, $data[‘post_title’] );
 *  $words = array_map( function( $word ) use ( $protected_words ) {
    return in_array(
   $word, $protected_words ) ? $word : mb_strtoupper( $word, ‘UTF-8’ ); }, $words);
 *  // There is no mb_ucfirst()
    $words[0] = mb_convert_case( $words[0], MB_CASE_UPPER,“
   UTF-8”);
 *  $data[‘post_title’] = join( ‘ ‘, $words );
 *  return $data;
    } else{ return $data; } });

The topic ‘wp_insert_post_data, Publishing failed’ is closed to new replies.

 * ![](https://ps.w.org/gutenberg/assets/icon-256x256.jpg?rev=1776042)
 * [Gutenberg](https://wordpress.org/plugins/gutenberg/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gutenberg/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gutenberg/)
 * [Active Topics](https://wordpress.org/support/plugin/gutenberg/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gutenberg/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gutenberg/reviews/)

## Tags

 * [Gutenberg editor](https://wordpress.org/support/topic-tag/gutenberg-editor/)
 * [publishing failed](https://wordpress.org/support/topic-tag/publishing-failed/)

 * 0 replies
 * 1 participant
 * Last reply from: [Kru-x](https://wordpress.org/support/users/mrkrux/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/wp_insert_post_data-publishing-failed/)
 * Status: not resolved