2017-05-29 67 views

回答

2

你必须使用WordPress插件激活钩添加一个名为“register_activation_hook”新的一页。它会在您的插件激活时调用。

register_activation_hook(__FILE__, 'insert_page'); 

function insert_page(){ 
    // Create post object 
    $pageArray = array(
     'post_title' => 'My Page', 
     'post_content' => 'This is my page.', 
     'post_status' => 'publish', 
     'post_author' => get_current_user_id(), 
     'post_type'  => 'page', 
    ); 

    // Insert the post into the database 
    wp_insert_post($pageArray, ''); 
}