2012-05-01 26 views

回答

1

關於WordPress Codex的wp_insert_post參考可能有所幫助。

這裏有一個如何以編程方式創建一個新的職位的示例代碼:

// Create post object 
    $my_post = array(
    'post_title' => 'My post', 
    'post_content' => 'This is my post.', 
    'post_status' => 'publish', 
    'post_author' => 1, 
    'post_category' => array(8,39) 
); 

// Insert the post into the database 
    wp_insert_post($my_post); 

自動運行該代碼時,你的插件被激活時,你可以在register_activation_hook鉤包裝這個代碼。

相關問題