如何自动创建一个WordPress页面(例如,当插件被激活时)?WordPress - 自动创建页面
11
A
回答
21
使用wp_insert_post()
,可插入网页,以及:http://codex.wordpress.org/Function_Reference/wp_insert_post
见下文post_type。
$post = array(
'ID' => [ <post id> ] //Are you updating an existing post?
'menu_order' => [ <order> ] //If new post is a page, sets the order should it appear in the tabs.
'page_template' => [ <template file> ] //Sets the template for the page.
'comment_status' => [ 'closed' | 'open' ] // 'closed' means no comments.
'ping_status' => [ ? ] //Ping status?
'pinged' => [ ? ] //?
'post_author' => [ <user ID> ] //The user ID number of the author.
'post_category' => [ array(<category id>, <...>) ] //Add some categories.
'post_content' => [ <the text of the post> ] //The full text of the post.
'post_date' => [ Y-m-d H:i:s ] //The time post was made.
'post_date_gmt' => [ Y-m-d H:i:s ] //The time post was made, in GMT.
'post_excerpt' => [ <an excerpt> ] //For all your post excerpt needs.
'post_name' => [ <the name> ] // The name (slug) for your post
'post_parent' => [ <post ID> ] //Sets the parent of the new post.
'post_password' => [ ? ] //password for post?
'post_status' => [ 'draft' | 'publish' | 'pending' ] //Set the status of the new post.
'post_title' => [ <the title> ] //The title of your post.
'post_type' => [ 'post' | 'page' ] //Sometimes you want to post a page.
'tags_input' => [ '<tag>, <tag>, <...>' ] //For tags.
'to_ping' => [ ? ] //?
);
// Insert the post into the database
wp_insert_post($post);
+1
因为页面只是标记为页面的帖子。 – 2009-07-27 01:12:13
-3
WordPress的提供了数据库抽象的wp->查询API方法。您可以创建适当的查询以在需要时创建页面。
相关问题
- 1. 如何创建自定义WordPress页面?
- 2. php自动创建页面
- 3. 自动创建页面
- 4. 在wordpress用户页面创建列
- 5. 使用wordpress plgin创建自定义页面
- 6. 创建WordPress的自定义页面,并添加内容到它
- 7. 是否可以创建自定义页面并使用WordPress Codex?
- 8. 如何在wordpress中创建多个自定义页面?
- 9. 为Wordpress创建自定义php登录页面
- 10. WordPress的 - 用PHP代码创建自定义页面
- 11. 如何在Wordpress中创建自定义页面?
- 12. 如何在wordpress中创建自定义错误页面?
- 13. 创建个别页面或动态创建页面?
- 14. 动态页面创建.aspx
- 15. ASP.NET动态创建页面
- 16. 创建自定义页面模板
- 17. 在WordPress中为插件查看页面创建一个页面
- 18. 如何从模板页面在wordpress中创建新页面?
- 19. 创建Wordpress插件页面,类似于帖子页面
- 20. 如何在wordpress中为父页面创建子页面
- 21. 如何在WordPress中创建启动页面
- 22. 对动态创建页面的WordPress评论
- 23. React路由器:从Wordpress REST API动态创建页面
- 24. 创建WordPress自定义帖子类型的手动分页
- 25. 如何用wordpress页眉和页脚创建静态页面?
- 26. WordPress的+自定义页面
- 27. WordPress的自定义页面
- 28. Wordpress自定义URL页面
- 29. 动态创建静态页面的动态页面
- 30. 如何在wordpress管理面板中创建新页面
你是什么意思?你想编写一个使用wp核心API创建页面的插件吗? – 2009-07-27 01:06:51
是的,就是这样。我想创建NEW页面,而不是在某处插入现有的页面。 – Phil 2009-07-27 13:26:26