WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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));
share|improve this question

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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