Q: wp_insert_post truncates post content on quotes... is there a proper way to escape these things?

Elite
  • 572 points
    Like some sort of WPMU DEV God"
    I'm helpful
    David

    Member  —  5th June 2010 (1 year ago)         

    So, I've made my first attempt to import from the old CMS. When I bring in content, I've noticed that wp_insert_post seems to truncate the post_content array element on quotes (and possibly other things).

    If I want to make sure content is imported as specified, what do I have to do to the content first? Do I have to run some kind of magic quotes thing, or some level of escape code?

    Basically:

    $my_post = array();
                  $my_post['post_title'] = $title;
                  $my_post['post_content'] = $article;
                  $my_post['post_status'] = 'publish';
                  $my_post['post_author'] = 1;
                  $my_post['post_type'] = 'page';
                  $new_id = wp_insert_post( $my_post );

    But $article is getting truncated. I'm assuming I should have something like:

    `$article = clean_me_up_somehow($article); before the insert, but I don't know what that is, and I can't check 100,000 pages individually once I flip the switch and do the import.

    Help appreciated.