如何自動創建一個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