[wp-hackers] Escaping post meta values

Dan Phiffer dan at phiffer.org
Wed May 22 15:46:46 UTC 2013

Hi wp-hackers,

What's the deal with post meta value escaping? I didn't see any mention of it in the documentation, but it seems important if you're ever going to store JSON data in the postmeta table (i.e., {"key":"value with \"quotes\" in the content."})

Reduced example:

$str1 = '\\"';
update_post_meta($post->ID, "test", $str1);
$str2 = get_post_meta($post->ID, "test", true);

echo "$str1<br>$str2";



More information about the wp-hackers mailing list