2012-05-01 30 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钩包装这个代码。

相关问题