【发布时间】:2014-10-21 13:50:56
【问题描述】:
我开发了一个 WordPress 插件,它是一个复杂的插件,现在我想创建一个属于 Page Parent 的 Page Parent 和 Child Pages。
我的页面创建代码如下,第一个函数将创建一个父页面,第二个函数也在创建一个父页面,我无法创建第一个页面的子页面,有 post_parent 但如何获取我首先创建的那个页面父级?
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
【问题讨论】: