通常,我会转到仪表板来设置pages父属性。假设我正在动态地创建一个页面,所以它无法通过仪表板进行编辑,是否有一种以编程方式设置父属性的方法?
谢谢
发布于 2013-12-31 16:51:47
您可以查看wp_insert_post()函数。它接受一个$post数组,您可以设置父ID.。
下面是一个例子:
// Create post object
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
'post_parent' => [ <post ID> ], // Sets the parent of the new post, if any. Default 0.
'post_category' => array(8,39)
);
// Insert the post into the database
wp_insert_post( $my_post );我希望它能帮上忙!-用例子更新
发布于 2013-12-31 16:51:11
检查wp_insert_post - post
您可以通过post_parent参数设置post父级。
https://stackoverflow.com/questions/20860542
复制相似问题