How-to stop wordpress from saving utf8 non-breaking space characters

Both initial creation and updates for the posts pass through wp_insert_post_data (among other filters). You can modify post_content item in array passed to make the replacement you need, before it proceeds on to be saved in database.

Update Code pasted from comments

add_filter( 'wp_insert_post_data', 'rm_wp_insert_post_data', '99', 2 );
function rm_wp_insert_post_data ( $data , $postarr ) {
   return str_replace("\xc2\xa0", " ", $data); 
}

Leave a Comment