我已使用此代码更新帖子$x = wp_update_post($post);
但它根本没有更新任何信息。以下是已发送到函数的$ post数组的内容。这里它返回582因此它是成功的。我不知道还有其他办法吗?有一些自定义帖子元和帖子类型是照片自定义。
Array
(
[ID] => 582
[upload_title] => Flower Warriors
[upload_desc] => Aenean condimentum massa id leo ullamcorper
[upload_keywords] => Blog, Demo, Flower, Images
[upload_price] => 58
[extra_categories] => Array
(
[0] => 6
[1] => 8
[2] => 10
[3] => 18
[4] => 19
[5] => 23
)
[property_release] => 2
[release_info] => Tinterdum lacus eget hendrerit? Quisque a turpis sit amet est consequat vestibulum.
[large_price] => 39
[medium_price] => 18
[small_price] => 14
)
答案 0 :(得分:0)
wp_update_post不会更新自定义字段。对于那些你需要做的事情:
add_post_meta($ id,'upload_title','Flower Warriors',true)或update_post_meta($ id,'upload_title','Flower Warriors');
最简单的方法是将自定义字段添加到单独的变量中并在其上运行foreach循环。
//$id is the ID of the post you're updating
foreach ($cf as $k => $v) :
add_post_meta($id, $k, $v, true) or update_post_meta($id, $k, $v);
endforeach;