I'm having trouble with inserting a string which is containing quotation marks in wordpress via wpdb.

I've written a hook for save_post and trying to write the post_title in a table via wpdp->update.

String is taken straight from the $_POST array. Unfortunatly, in the db the string is saved with escaped quotation marks.

this is "the" example will become -> this is \"the\" example printed out in html.

How can I prevent this?

Code looks like this:

$data = array(  'post_content' => $new_content,
                            'post_title' => $new_title);

            $wpdb->update('wp_'.$blog_id.'_posts', $data, array('ID' => $post_id));

2 Answers 2


Try stripslashes. See the php documentation.

To clarify, the slashes are inserted to escape the content prior to insertion into the database. You should use the above function when you want to display the content.


String is taken straight from the $_POST array.

WordPress automatically applies slash escaping to data in $_POST. You will need to stripslashes on the posted data before inserting it into the DB.

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.