Let me tell you my story... I was having an issue with  char visible within the post's content. Instead of editing each one, I was passing a simple query:

UPDATE wp_posts SET post_content = REPLACE( post_content, binary 'Â', '' );

Everything was fine so far, however, after adding new posts the issue was back again, so I thought trigger would be the key! So I've written one as follows:

CREATE TRIGGER watch_posts 
  AFTER INSERT ON wp_posts 
  UPDATE wp_posts SET post_content = REPLACE( post_content, binary 'Â', '' );

From this point within most of the posts I'm having now blank edit page where word count is equal to 0. But the database still consist of post_content which is not empty. How to prevent existing posts to not be blank anymore?

  • 2
    First I'd remove that trigger. Next I'd disable all plugins, check to see if the  problem is gone (by adding a new test post, if necessary). If it's gone, re-enable plugins one by one till you find the problem. If it's not a plugin, try switching to a default theme (eg, Twenty Sixteen) and see if the problem is cured or if it persists.
    – Pat J
    Nov 1, 2016 at 21:23
  • 1
    and if the problem remains after all the tests that @PatJ speaks about, it may be better to clean this caracter with a plugin instead of editing the database
    – mmm
    Nov 1, 2016 at 21:25
  • Looks like you are using the wrong charset on some of your DB tables.
    – kaiser
    Nov 19, 2016 at 0:21

1 Answer 1


I've written a filter for you. It will filter the character before the post get saved in the database and it's using the WordPress way. If you use this I think you're not gonna be needed the trigger. Here it is-

add_filter( 'wp_insert_post_data' , 'the_dramatist_filter_content_before_insert' , '99', 2 );

function the_dramatist_filter_content_before_insert( $data , $postarr ) {

    $search  = array('Â'); // You can add other replacement finding here also
    $replace = array(''); // The replacements

    $data['post_content'] = str_replace($search, $replace, $data['post_content']);

    // Now just return the data
    return $data;

Hope that thing helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.