【发布时间】:2014-06-03 05:08:40
【问题描述】:
我正在编写的脚本中使用 wp_insert_post(出于多种原因),它会导致其中包含撇号的任何字符串被截断为该字符(包括该字符)。这是我必须测试的代码:
$question = "If you’re in need, this is who you call";
echo $question."<br />";
$post = array(
'post_title' => $question,
'post_status' => 'publish',
'post_type' => 'question'
);
echo $post['post_title'];
$the_post_id = wp_insert_post($post);
这很奇怪,因为当我回显两个字符串时,两端都回显了正确的内容,因此我将其隔离到导致问题的 wp_insert_post 函数。当我在 WordPress 中查看时,标题只是“如果你”,然后结束。
我在这里发现了类似的问题:
http://premium.wpmudev.org/forums/topic/q-wp_insert_post-truncates-post-content-on-quotes-is-there-a-proper-way-to-escape-these-things
但该页面上似乎没有任何解决方案。关于这里发生了什么以及如何解决它的任何想法?不知道为什么会导致它。我正在查看它是否与我的代码中的其他内容有关,但它似乎不应该因为数组元素在 wp_insert_post() 函数之前回显时似乎格式化得很好。
感谢您的帮助!
【问题讨论】:
标签: php arrays wordpress foreach