WordPress post text corruption WordPress post text corruption wordpress wordpress

WordPress post text corruption


according to your explanation the problem seems to be with the WordPress core, I'll recommend you to try a different approach:

  1. Insert a post using wp_insert_post function but without content or a "safe" content like one simple word.
  2. Then use $wpdb to update the post with the real content.

Here is a snipped of how I'll do it:

  $my_post = array(     'post_title' => 'Caption',     'post_status' => 'publish',     'post_content' => 'dummy text'  );//get the post id  $post_id = wp_insert_post( $my_post );global $wpdb;//now update the post with the real text$wpdb->update(      $wpdb->prefix . 'posts',     array(         'post_content' => 'YOUR LONG TEXT HERE',        ),     array( 'ID' => $post_id ),     array('%s'),     array('%d') );

If you don't get the result you want with this, then is a problem with your php config or MySQL configuration unless you are willing to try a more unfriendly solution and use $wpdb->query instead of $wpdb->update like this:

$big_text = "YOUR BIG TEXT HERE";$wpdb->query(    "UPDATE $wpdb->posts     SET post_content = $big_text    WHERE ID = $post_id");

Let us know.


Make sure the articles you are transferring over have no embedded character encoding. This is a common problem when you try to copy over stuff from a formatted document like a Microsoft Word doc, since it saves character encoding information when the text is copied.

In the WordPress WYSIWYG box, there is an icon to reveal source code. You might be able to spot strange character encoding by viewing this.

Else, try pasting your articles in a text editor and converting all the text to standard UTF-8 encoding before pasting into WordPress.


Have you tried to disable mod_security (through .htaccess)?

<IfModule mod_security.c>SecFilterEngine OffSecFilterScanPOST Off</IfModule>

There are a lot of people complaining about problems related to saving long posts in Wordpress, or posts which can't be saved because of certain words. That's because sometimes Wordpress won't play nicely with mod_security enabled. Some of them solved this by disabling this feature...Some of them solved this by changing WP memory limit... Maybe some of these will help you to solve your problem (or at least to narrow it down).