i developed an WordPress plugin,it is a complex plugin,a nd now what remained to do i want to create a Page Parent and Child Pages that belongs to Page Parent.
My code for page creation is below, first function will create a parent page, and second function is also creating a parent page, i can not make a child of the first page, there is post_parent but how to get the id of that page parent that i create first?
register_activation_hook( __FILE__, 'create_page_1_parent');
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 );
}
register_activation_hook( __FILE__, 'create_page_1_parent_child');
function create_page_1_parent_child()
{
//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' => '', //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