如何使用类似于add\\u post\\u meta()、update\\u post\\u meta()的硬PHP代码更新/添加新标题、帖子内容和类别?
添加标题、帖子内容和类别,如添加_post_meta和更新_post_meta
1 个回复
最合适的回答,由SO网友:scribu 整理而成
通过使用wp_update_post()
, 可在wp includes/post中找到。php:
// Update post 42
$post = array();
$post[\'ID\'] = 42;
$post[\'post_category\'] = array( ... );
$post[\'post_content\' ] = \'This is the updated content.\';
$post[\'post_title\' ] = \'This is the updated title.\';
// Update the post into the database
wp_update_post( $post );
结束