Php Wordpress插件自动创建父页面和相关父页面的子页面

Php Wordpress插件自动创建父页面和相关父页面的子页面,php,wordpress,Php,Wordpress,我开发了一个WordPress插件,它是一个复杂的插件,现在我要做的是创建一个属于父页面的父页面和子页面 我的页面创建代码如下,第一个函数将创建一个父页面,第二个函数也将创建一个父页面,我不能创建第一个页面的子页面,有post_父页面,但如何获取我首先创建的页面父页面的id register_activation_hook(__文件,'create_page_1_parent'); 函数create_page_1_parent() { //职位状态和选项 $post=数组( “评论状态”=>“已

我开发了一个WordPress插件,它是一个复杂的插件,现在我要做的是创建一个属于父页面的父页面和子页面

我的页面创建代码如下,第一个函数将创建一个父页面,第二个函数也将创建一个父页面,我不能创建第一个页面的子页面,有post_父页面,但如何获取我首先创建的页面父页面的id

register_activation_hook(__文件,'create_page_1_parent');
函数create_page_1_parent()
{
//职位状态和选项
$post=数组(
“评论状态”=>“已关闭”,
“ping_状态”=>“已关闭”,
“后作者”=>1,
“发布日期”=>日期(“Y-m-d H:i:s”),
“职位名称”=>“第一职位”,
“发布状态”=>“发布”,
“post_title”=>“parent”,
“post_type”=>“page”,
“post_parent'=>”,
“发布内容”=>“[il\U登录表单]”
);
//插入页面并保存id
$newvalue=wp\u insert\u post($post,false);
//将id保存在数据库中
更新_选项('hclpage',$newvalue);
}
注册激活钩子(uuu文件uuu,‘创建页面u 1 u父项u子项’);
函数create_page_1_parent_child()
{
//职位状态和选项
$post=数组(
“评论状态”=>“已关闭”,
“ping_状态”=>“已关闭”,
“后作者”=>1,
“发布日期”=>日期(“Y-m-d H:i:s”),
“职位名称”=>“第一职位”,
“发布状态”=>“发布”,
“post_title”=>“parent”,
“post_type”=>“page”,
'post_parent'=>'',//我必须在此处放置的内容将转到udner父页面
“发布内容”=>“[il\U登录表单]”
);
//插入页面并保存id
$newvalue=wp\u insert\u post($post,false);
//将id保存在数据库中

只需在1函数中执行两个插入

function create_page_1_parent()
{
    //post status and options
    $post = array(
        'comment_status' => 'closed',
        'ping_status' =>  'closed' ,
        'post_author' => 1,
        'post_date' => date('Y-m-d H:i:s'),
        'post_name' => '1first post',
        'post_status' => 'publish' ,
        'post_title' => 'parent',
        'post_type' => 'page',
        'post_parent' => '',
        'post_content' => '[il_login_form]'
    );
    //insert page and save the id
    $newvalue = wp_insert_post( $post, false );
    //save the id in the database
    update_option( 'hclpage', $newvalue );

    //post status and options
    $post = array(
        'comment_status' => 'closed',
        'ping_status' =>  'closed' ,
        'post_author' => 1,
        'post_date' => date('Y-m-d H:i:s'),
        'post_name' => '1first post',
        'post_status' => 'publish' ,
        'post_title' => 'parent',
        'post_type' => 'page',
        'post_parent' => $newvalue, //what i have to put here that will go udner parent page
        'post_content' => '[il_login_form]'
    );
    //insert page and save the id
    $newvalue = wp_insert_post( $post, false );
    //save the id in the database
}