Title: Updated Version to replace Sensitive Characters
Last modified: June 24, 2020

---

# Updated Version to replace Sensitive Characters

 *  [TheMummichogblogdotcom](https://wordpress.org/support/users/mummichogblog/)
 * (@mummichogblog)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/updated-version-to-replace-sensitive-characters/)
 * I am using it on my blog [http://themummichoblog.com](http://themummichoblog.com)
 * However, whenever there was a special character in the beginning of the text 
   I got a blank post due to special characters.
 * Modified the code to replace the post data and remove special characters. Using
   it with the current latest version of WordPress.
 * Ideally a new version is created so everyone can benefit.
 * —
    <?php /* Plugin Name: Auto Generate Title Author: Jatinder Pal Singh, Themummichogblog.
   com Version: 1.2 Tags: post title, title, automatic, generator Requires at least:
   3.0.1 Tested up to: 5.4.2 Stable tag: 1.1 License: GPLv2 or later License URI:
   [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)
   Description: Auto Generate Title from the POST Content. If you leave Title blank,
   it will use the text written in [agt][/agt] within your post content. If you 
   do not mention these shortcodes in your post, It will pick up first 30 characters
   from the post.
 * Changes:
    1) $postdata2 = preg_replace(“/[^A-Za-z0-9 ]/”, ”, $postdata); 2) $
   data[‘post_title’] = substr($postdata2,0,30);
 * */
 * add_shortcode(“agt”, “agt_shortcode”);
    function agt_shortcode( $atts, $content
   = null ) { return $content; }
 * add_filter( ‘wp_insert_post_data’ , ‘auto_generate_title’ , ’99’, 2 );
    function
   auto_generate_title( $data , $postarr ) {
 *  $title_of_post = ltrim($data[‘post_title’]);
    $length_of_title = strlen($title_of_post);
   $postdata = ltrim($data[‘post_content’]); $postdata2 = preg_replace(“/[^A-Za-
   z0-9 ]/”, ”, $postdata); if($length_of_title<1) { $matchPattern = “/\[agt\](.*?)\[\/
   agt\]/”; preg_match_all($matchPattern, $postdata, $foundIt, PREG_PATTERN_ORDER);
   if (isset($foundIt[1][0])) $data[‘post_title’] = $foundIt[1][0]; else $data[‘
   post_title’] = substr($postdata2,0,30); } return $data; } ?>
    -  This topic was modified 5 years, 11 months ago by [TheMummichogblogdotcom](https://wordpress.org/support/users/mummichogblog/).

The topic ‘Updated Version to replace Sensitive Characters’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/auto-generate-title.svg)
 * [Auto Generate Title](https://wordpress.org/plugins/auto-generate-title/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/auto-generate-title/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/auto-generate-title/)
 * [Active Topics](https://wordpress.org/support/plugin/auto-generate-title/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/auto-generate-title/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/auto-generate-title/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [TheMummichogblogdotcom](https://wordpress.org/support/users/mummichogblog/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/updated-version-to-replace-sensitive-characters/)
 * Status: not a support question