2012-07-13 145 views
0

我正在为wordpress编写插件,并且在此插件中管理员应该添加一些像这样的信息===>标题,数据库中的文本。wordpress添加页面

我想将这些信息添加为数据库中的wordpress页面。

我应该使用什么函数来完成此任务?

回答

2

您可以使用wp_insert_posthttp://codex.wordpress.org/Function_Reference/wp_insert_post

页面只是一个类型WP职位。

$post = array(
    'post_title' => 'my Title', 
    'post_content' => 'my Text', 
    'post_type' => 'page', 

    'post_status' => 'publish', 
    'post_author' => 1 
); 

wp_insert_post($post); 
+0

嗯,我新的这个功能只是争取没有尝试的页面将是其他:)。谢谢你对我的帮助 – 2012-07-13 15:00:01

+1

不客气:) http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – 2012-07-13 15:41:16